@Override
public ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> ctx) {
- return new ConfigStatementImpl(ctx);
+ final ConfigStatement ret = new ConfigStatementImpl(ctx);
+
+ if (EmptyConfigStatement.FALSE.equals(ret)) {
+ return EmptyConfigStatement.FALSE;
+ } else if (EmptyConfigStatement.TRUE.equals(ret)) {
+ return EmptyConfigStatement.TRUE;
+ } else {
+ return ret;
+ }
}
@Override
public EffectiveStatement<Boolean, ConfigStatement> createEffective(
final StmtContext<Boolean, ConfigStatement, EffectiveStatement<Boolean, ConfigStatement>> ctx) {
- return new ConfigEffectiveStatementImpl(ctx);
+ final EffectiveStatement<Boolean, ConfigStatement> ret = new ConfigEffectiveStatementImpl(ctx);
+ final ConfigStatement declared = ret.getDeclared();
+ if (declared instanceof EmptyConfigStatement && ret.effectiveSubstatements().isEmpty()) {
+ return ((EmptyConfigStatement)declared).toEffective();
+ }
+ return ret;
}
@Override
--- /dev/null
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ConfigEffectiveStatement;
+
+abstract class EmptyConfigEffectiveStatement implements ConfigEffectiveStatement {
+ static final EmptyConfigEffectiveStatement FALSE = new EmptyConfigEffectiveStatement() {
+ @Override
+ public ConfigStatement getDeclared() {
+ return EmptyConfigStatement.FALSE;
+ }
+ };
+
+ static final EmptyConfigEffectiveStatement TRUE = new EmptyConfigEffectiveStatement() {
+ @Override
+ public ConfigStatement getDeclared() {
+ return EmptyConfigStatement.TRUE;
+ }
+ };
+
+ private EmptyConfigEffectiveStatement() {
+ // Hidden
+ }
+
+ @Override
+ public final StatementDefinition statementDefinition() {
+ return getDeclared().statementDefinition();
+ }
+
+ @Override
+ public final Boolean argument() {
+ return getDeclared().argument();
+ }
+
+ @Override
+ public final StatementSource getStatementSource() {
+ return getDeclared().getStatementSource();
+ }
+
+ @Override
+ public final <K, V, N extends IdentifierNamespace<K, V>> V get(final Class<N> namespace, final K identifier) {
+ throw new UnsupportedOperationException("Not implemented yet.");
+ }
+
+ @Override
+ public final <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(final Class<N> namespace) {
+ throw new UnsupportedOperationException("Not implemented yet.");
+ }
+
+ @Override
+ public final Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+ return ImmutableList.of();
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import java.util.Objects;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+
+abstract class EmptyConfigStatement implements ConfigStatement {
+ static final ConfigStatement FALSE = new EmptyConfigStatement() {
+ @Override
+ public boolean getValue() {
+ return false;
+ }
+
+ @Override
+ EffectiveStatement<Boolean, ConfigStatement> toEffective() {
+ return EmptyConfigEffectiveStatement.FALSE;
+ }
+ };
+
+ static final ConfigStatement TRUE = new EmptyConfigStatement() {
+ @Override
+ public boolean getValue() {
+ return true;
+ }
+
+ @Override
+ EffectiveStatement<Boolean, ConfigStatement> toEffective() {
+ return EmptyConfigEffectiveStatement.TRUE;
+ }
+ };
+
+ private EmptyConfigStatement() {
+ // Invisible on purpose
+ }
+
+ abstract EffectiveStatement<Boolean, ConfigStatement> toEffective();
+
+ @Override
+ public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+ return ImmutableList.of();
+ }
+
+ @Override
+ public final StatementDefinition statementDefinition() {
+ return Rfc6020Mapping.CONFIG;
+ }
+
+ @Override
+ public final String rawArgument() {
+ return Boolean.toString(getValue());
+ }
+
+ @Override
+ public final Boolean argument() {
+ return Boolean.valueOf(getValue());
+ }
+
+ @Override
+ public final StatementSource getStatementSource() {
+ return StatementSource.DECLARATION;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(statementDefinition(), getStatementSource(), argument(),
+ rawArgument(), declaredSubstatements(), getValue());
+ }
+
+ @Override
+ public final boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof ConfigStatement)) {
+ return false;
+ }
+
+ final ConfigStatement other = (ConfigStatement) obj;
+
+ return getValue() == other.getValue() && argument().equals(other.argument()) &&
+ rawArgument().equals(other.rawArgument()) &&
+ statementDefinition().equals(other.statementDefinition()) &&
+ getStatementSource().equals(other.getStatementSource()) &&
+ declaredSubstatements().equals(other.declaredSubstatements());
+ }
+}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import com.google.common.collect.ImmutableList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Objects;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
@Override
public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
- return Collections.emptyList();
+ return ImmutableList.of();
}
@Override
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+
+public interface ConfigEffectiveStatement extends EffectiveStatement<Boolean, ConfigStatement> {
+
+}
import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-public final class ConfigEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, ConfigStatement> {
+public final class ConfigEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, ConfigStatement>
+ implements ConfigEffectiveStatement {
public ConfigEffectiveStatementImpl(final StmtContext<Boolean, ConfigStatement, ?> ctx) {
super(ctx);
}
this.deviateType = argument();
- final ConfigEffectiveStatementImpl configStmt = firstEffective(ConfigEffectiveStatementImpl.class);
+ final ConfigEffectiveStatement configStmt = firstEffective(ConfigEffectiveStatement.class);
this.deviatedConfig = configStmt == null ? null : configStmt.argument();
final DefaultEffectiveStatementImpl defaultStmt = firstEffective(DefaultEffectiveStatementImpl.class);
this.deviatedDefault = defaultStmt == null ? null : defaultStmt.argument();
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
return Objects.hash(deviateType, deviatedConfig, deviatedDefault, deviatedMandatory, deviatedMaxElements,
deviatedMinElements, deviatedMustDefinitions, deviatedType, deviatedUniqueConstraints, deviatedUnits);
}
-}
\ No newline at end of file
+}