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 org.eclipse.jdt.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 @NonNull MandatoryStatement FALSE = new EmptyMandatoryStatement() {
24 public Boolean argument() {
29 EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
30 return EmptyMandatoryEffectiveStatement.FALSE;
34 static final @NonNull MandatoryStatement TRUE = new EmptyMandatoryStatement() {
36 public Boolean argument() {
41 EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
42 return EmptyMandatoryEffectiveStatement.TRUE;
46 abstract EffectiveStatement<Boolean, MandatoryStatement> toEffective();
49 public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
50 return ImmutableList.of();
54 public final StatementDefinition statementDefinition() {
55 return YangStmtMapping.MANDATORY;
59 public final String rawArgument() {
60 return getValue().toString();
64 public final StatementSource getStatementSource() {
65 return StatementSource.DECLARATION;
69 public final int hashCode() {
70 return Objects.hash(statementDefinition(), getStatementSource(), argument(),
71 rawArgument(), declaredSubstatements(), getValue());
75 public final boolean equals(final Object obj) {
79 if (!(obj instanceof MandatoryStatement)) {
83 final MandatoryStatement other = (MandatoryStatement) obj;
84 return argument().equals(other.argument())
85 && rawArgument().equals(other.rawArgument())
86 && getValue().equals(other.getValue())
87 && statementDefinition().equals(other.statementDefinition())
88 && getStatementSource().equals(other.getStatementSource())
89 && declaredSubstatements().equals(other.declaredSubstatements());