2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.mandatory;
10 import com.google.common.collect.ImmutableList;
11 import java.util.Collection;
12 import java.util.Objects;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
15 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
18 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
19 import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
21 abstract class EmptyMandatoryStatement implements MandatoryStatement {
22 static final MandatoryStatement FALSE = new EmptyMandatoryStatement() {
24 public Boolean argument() {
29 EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
30 return EmptyMandatoryEffectiveStatement.FALSE;
34 static final MandatoryStatement TRUE = new EmptyMandatoryStatement() {
36 public Boolean argument() {
41 EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
42 return EmptyMandatoryEffectiveStatement.TRUE;
46 abstract EffectiveStatement<Boolean, MandatoryStatement> toEffective();
50 public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
51 return ImmutableList.of();
56 public final StatementDefinition statementDefinition() {
57 return YangStmtMapping.MANDATORY;
61 public final String rawArgument() {
62 return getValue().toString();
67 public final StatementSource getStatementSource() {
68 return StatementSource.DECLARATION;
72 public final int hashCode() {
73 return Objects.hash(statementDefinition(), getStatementSource(), argument(),
74 rawArgument(), declaredSubstatements(), getValue());
78 public final boolean equals(final Object obj) {
82 if (!(obj instanceof MandatoryStatement)) {
86 final MandatoryStatement other = (MandatoryStatement) obj;
87 return argument().equals(other.argument())
88 && rawArgument().equals(other.rawArgument())
89 && getValue().equals(other.getValue())
90 && statementDefinition().equals(other.statementDefinition())
91 && getStatementSource().equals(other.getStatementSource())
92 && declaredSubstatements().equals(other.declaredSubstatements());