2 * Copyright (c) 2016 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.config;
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.ConfigStatement;
21 abstract class EmptyConfigStatement implements ConfigStatement {
22 static final @NonNull ConfigStatement FALSE = new EmptyConfigStatement() {
24 public Boolean argument() {
29 EffectiveStatement<Boolean, ConfigStatement> toEffective() {
30 return EmptyConfigEffectiveStatement.FALSE;
34 static final @NonNull ConfigStatement TRUE = new EmptyConfigStatement() {
36 public Boolean argument() {
41 EffectiveStatement<Boolean, ConfigStatement> toEffective() {
42 return EmptyConfigEffectiveStatement.TRUE;
46 abstract EffectiveStatement<Boolean, ConfigStatement> toEffective();
49 public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
50 return ImmutableList.of();
54 public final StatementDefinition statementDefinition() {
55 return YangStmtMapping.CONFIG;
59 public final String rawArgument() {
60 return Boolean.toString(getValue());
64 public final StatementSource getStatementSource() {
65 return StatementSource.DECLARATION;
69 public final int hashCode() {
70 return Objects.hash(statementDefinition(), getStatementSource(), argument(), rawArgument(),
71 declaredSubstatements(), getValue());
75 public final boolean equals(final Object obj) {
79 if (!(obj instanceof ConfigStatement)) {
83 final ConfigStatement other = (ConfigStatement) obj;
85 return getValue() == other.getValue() && argument().equals(other.argument())
86 && rawArgument().equals(other.rawArgument())
87 && statementDefinition().equals(other.statementDefinition())
88 && getStatementSource().equals(other.getStatementSource())
89 && declaredSubstatements().equals(other.declaredSubstatements());