--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNull;
+
+@Beta
+public abstract class AbstractBooleanDeclaredStatement extends AbstractDeclaredStatement<Boolean> {
+ private final @NonNull Boolean argument;
+
+ protected AbstractBooleanDeclaredStatement(final Boolean argument) {
+ this.argument = requireNonNull(argument);
+ }
+
+ @Override
+ public final @NonNull Boolean argument() {
+ return argument;
+ }
+
+ @Override
+ public final String rawArgument() {
+ return argument.toString();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.annotations.Beta;
+import org.eclipse.jdt.annotation.NonNull;
+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.parser.spi.meta.StmtContext;
+
+/**
+ * Specialization of {@link BaseStatementSupport} for Boolean statement arguments.
+ *
+ * @param <D> Declared Statement representation
+ * @param <E> Effective Statement representation
+ */
+@Beta
+public abstract class BaseBooleanStatementSupport<D extends DeclaredStatement<Boolean>,
+ E extends EffectiveStatement<Boolean, D>> extends BaseStatementSupport<Boolean, D, E> {
+ private final @NonNull E emptyEffectiveFalse;
+ private final @NonNull E emptyEffectiveTrue;
+ private final @NonNull D emptyDeclaredFalse;
+ private final @NonNull D emptyDeclaredTrue;
+
+ protected BaseBooleanStatementSupport(final StatementDefinition publicDefinition,
+ final E emptyEffectiveFalse, final E emptyEffectiveTrue) {
+ super(publicDefinition);
+ this.emptyEffectiveFalse = requireNonNull(emptyEffectiveFalse);
+ this.emptyEffectiveTrue = requireNonNull(emptyEffectiveTrue);
+ emptyDeclaredFalse = requireNonNull(emptyEffectiveFalse.getDeclared());
+ emptyDeclaredTrue = requireNonNull(emptyEffectiveTrue.getDeclared());
+ }
+
+ @Override
+ public final Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ return ArgumentUtils.parseBoolean(ctx, value);
+ }
+
+ @Override
+ public final String internArgument(final String rawArgument) {
+ return ArgumentUtils.internBoolean(rawArgument);
+ }
+
+ @Override
+ protected final D createEmptyDeclared(final StmtContext<Boolean, D, ?> ctx) {
+ return ctx.coerceStatementArgument() ? emptyDeclaredTrue : emptyDeclaredFalse;
+ }
+
+ @Override
+ protected final E createEmptyEffective(final StmtContext<Boolean, D, E> ctx, final D declared) {
+ if (emptyDeclaredTrue.equals(declared)) {
+ return emptyEffectiveTrue;
+ } else if (emptyDeclaredFalse.equals(declared)) {
+ return emptyEffectiveFalse;
+ } else {
+ return createEmptyEffective(declared);
+ }
+ }
+
+ protected abstract @NonNull E createEmptyEffective(@NonNull D declared);
+}
/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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,
import org.opendaylight.yangtools.yang.model.api.stmt.ConfigEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
-public final class ConfigEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, ConfigStatement>
+abstract class AbstractConfigEffectiveStatement
+ extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, ConfigStatement>
implements ConfigEffectiveStatement {
- public ConfigEffectiveStatementImpl(final StmtContext<Boolean, ConfigStatement, ?> ctx) {
- super(ctx);
+ AbstractConfigEffectiveStatement(final ConfigStatement declared) {
+ super(declared);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt.config;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractConfigStatement extends AbstractBooleanDeclaredStatement implements ConfigStatement {
+ AbstractConfigStatement(final Boolean argument) {
+ super(argument);
+ }
+
+ @Override
+ public StatementDefinition statementDefinition() {
+ return YangStmtMapping.CONFIG;
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.rfc7950.stmt.config;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class ConfigStatementImpl extends AbstractDeclaredStatement<Boolean> implements ConfigStatement {
- ConfigStatementImpl(final StmtContext<Boolean, ConfigStatement, ?> context) {
- super(context);
- }
-}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.config;
+import com.google.common.collect.ImmutableList;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.ConfigEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
public final class ConfigStatementSupport
- extends AbstractStatementSupport<Boolean, ConfigStatement, ConfigEffectiveStatement> {
+ extends BaseBooleanStatementSupport<ConfigStatement, ConfigEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.CONFIG).build();
private static final ConfigStatementSupport INSTANCE = new ConfigStatementSupport();
private ConfigStatementSupport() {
- super(YangStmtMapping.CONFIG);
+ super(YangStmtMapping.CONFIG, new EmptyConfigEffectiveStatement(new EmptyConfigStatement(Boolean.FALSE)),
+ new EmptyConfigEffectiveStatement(new EmptyConfigStatement(Boolean.TRUE)));
}
public static ConfigStatementSupport getInstance() {
}
@Override
- public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return ArgumentUtils.parseBoolean(ctx, value);
- }
-
- @Override
- public ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> 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;
- }
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
@Override
- public ConfigEffectiveStatement createEffective(
- final StmtContext<Boolean, ConfigStatement, ConfigEffectiveStatement> ctx) {
- final ConfigEffectiveStatement ret = new ConfigEffectiveStatementImpl(ctx);
- final ConfigStatement declared = ret.getDeclared();
- if (declared instanceof EmptyConfigStatement && ret.effectiveSubstatements().isEmpty()) {
- return ((EmptyConfigStatement)declared).toEffective();
- }
- return ret;
+ protected ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularConfigStatement(ctx.coerceStatementArgument(), substatements);
}
@Override
- public String internArgument(final String rawArgument) {
- return ArgumentUtils.internBoolean(rawArgument);
+ protected ConfigEffectiveStatement createEffective(
+ final StmtContext<Boolean, ConfigStatement, ConfigEffectiveStatement> ctx,
+ final ConfigStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new RegularConfigEffectiveStatement(declared, substatements);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected EmptyConfigEffectiveStatement createEmptyEffective(final ConfigStatement declared) {
+ return new EmptyConfigEffectiveStatement(declared);
}
}
\ No newline at end of file
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.config;
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
-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.ConfigEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-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();
+final class EmptyConfigEffectiveStatement extends AbstractConfigEffectiveStatement {
+ EmptyConfigEffectiveStatement(final ConfigStatement declared) {
+ super(declared);
}
-
- @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();
- }
-
- @Override
- public abstract @NonNull ConfigStatement getDeclared();
}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.config;
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Objects;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
-import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-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.ConfigEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
-
-abstract class EmptyConfigStatement implements ConfigStatement {
- static final @NonNull ConfigStatement FALSE = new EmptyConfigStatement() {
- @Override
- public Boolean argument() {
- return Boolean.FALSE;
- }
-
- @Override
- ConfigEffectiveStatement toEffective() {
- return EmptyConfigEffectiveStatement.FALSE;
- }
- };
-
- static final @NonNull ConfigStatement TRUE = new EmptyConfigStatement() {
- @Override
- public Boolean argument() {
- return Boolean.TRUE;
- }
-
- @Override
- ConfigEffectiveStatement toEffective() {
- return EmptyConfigEffectiveStatement.TRUE;
- }
- };
-
- abstract ConfigEffectiveStatement toEffective();
-
- @Override
- public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
- return ImmutableList.of();
- }
-
- @Override
- public final StatementDefinition statementDefinition() {
- return YangStmtMapping.CONFIG;
- }
-
- @Override
- public final String rawArgument() {
- return Boolean.toString(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());
+final class EmptyConfigStatement extends AbstractConfigStatement {
+ EmptyConfigStatement(final Boolean argument) {
+ super(argument);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.config;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+
+final class RegularConfigEffectiveStatement extends AbstractConfigEffectiveStatement {
+ private final @NonNull Object substatements;
+
+ RegularConfigEffectiveStatement(final ConfigStatement declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(declared);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+ return unmaskList(substatements);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.config;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularConfigStatement extends AbstractConfigStatement {
+ private final @NonNull Object substatements;
+
+ RegularConfigStatement(final Boolean argument, final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ super(argument);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+ return unmaskList(substatements);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt.mandatory;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
+
+abstract class AbstractMandatoryEffectiveStatement
+ extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, MandatoryStatement>
+ implements MandatoryEffectiveStatement {
+ AbstractMandatoryEffectiveStatement(final MandatoryStatement declared) {
+ super(declared);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt.mandatory;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractMandatoryStatement extends AbstractBooleanDeclaredStatement implements MandatoryStatement {
+ AbstractMandatoryStatement(final Boolean argument) {
+ super(argument);
+ }
+
+ @Override
+ public StatementDefinition statementDefinition() {
+ return YangStmtMapping.MANDATORY;
+ }
+}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.mandatory;
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Map;
-import org.eclipse.jdt.annotation.NonNull;
-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.MandatoryEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-abstract class EmptyMandatoryEffectiveStatement implements MandatoryEffectiveStatement {
- static final EmptyMandatoryEffectiveStatement FALSE = new EmptyMandatoryEffectiveStatement() {
- @Override
- public MandatoryStatement getDeclared() {
- return EmptyMandatoryStatement.FALSE;
- }
- };
-
- static final EmptyMandatoryEffectiveStatement TRUE = new EmptyMandatoryEffectiveStatement() {
- @Override
- public MandatoryStatement getDeclared() {
- return EmptyMandatoryStatement.TRUE;
- }
- };
-
- @Override
- public final StatementDefinition statementDefinition() {
- return getDeclared().statementDefinition();
- }
-
- @Override
- public final Boolean argument() {
- return getDeclared().argument();
+final class EmptyMandatoryEffectiveStatement extends AbstractMandatoryEffectiveStatement {
+ EmptyMandatoryEffectiveStatement(final MandatoryStatement declared) {
+ super(declared);
}
-
- @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();
- }
-
- @Override
- public abstract @NonNull MandatoryStatement getDeclared();
}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.mandatory;
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
-import java.util.Objects;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
-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.MandatoryStatement;
-
-abstract class EmptyMandatoryStatement implements MandatoryStatement {
- static final @NonNull MandatoryStatement FALSE = new EmptyMandatoryStatement() {
- @Override
- public Boolean argument() {
- return Boolean.FALSE;
- }
-
- @Override
- EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
- return EmptyMandatoryEffectiveStatement.FALSE;
- }
- };
-
- static final @NonNull MandatoryStatement TRUE = new EmptyMandatoryStatement() {
- @Override
- public Boolean argument() {
- return Boolean.TRUE;
- }
-
- @Override
- EffectiveStatement<Boolean, MandatoryStatement> toEffective() {
- return EmptyMandatoryEffectiveStatement.TRUE;
- }
- };
-
- abstract EffectiveStatement<Boolean, MandatoryStatement> toEffective();
-
- @Override
- public final Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
- return ImmutableList.of();
- }
-
- @Override
- public final StatementDefinition statementDefinition() {
- return YangStmtMapping.MANDATORY;
- }
-
- @Override
- public final String rawArgument() {
- return getValue().toString();
- }
-
- @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 MandatoryStatement)) {
- return false;
- }
-
- final MandatoryStatement other = (MandatoryStatement) obj;
- return argument().equals(other.argument())
- && rawArgument().equals(other.rawArgument())
- && getValue().equals(other.getValue())
- && statementDefinition().equals(other.statementDefinition())
- && getStatementSource().equals(other.getStatementSource())
- && declaredSubstatements().equals(other.declaredSubstatements());
+final class EmptyMandatoryStatement extends AbstractMandatoryStatement {
+ EmptyMandatoryStatement(final Boolean argument) {
+ super(argument);
}
}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.rfc7950.stmt.mandatory;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class MandatoryEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, MandatoryStatement>
- implements MandatoryEffectiveStatement {
- MandatoryEffectiveStatementImpl(final StmtContext<Boolean, MandatoryStatement, ?> ctx) {
- super(ctx);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.rfc7950.stmt.mandatory;
-
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class MandatoryStatementImpl extends AbstractDeclaredStatement<Boolean> implements MandatoryStatement {
- MandatoryStatementImpl(final StmtContext<Boolean, MandatoryStatement, ?> context) {
- super(context);
- }
-}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.mandatory;
+import com.google.common.collect.ImmutableList;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.MandatoryEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
public final class MandatoryStatementSupport extends
- AbstractStatementSupport<Boolean, MandatoryStatement, EffectiveStatement<Boolean, MandatoryStatement>> {
+ BaseBooleanStatementSupport<MandatoryStatement, MandatoryEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.MANDATORY).build();
private static final MandatoryStatementSupport INSTANCE = new MandatoryStatementSupport();
private MandatoryStatementSupport() {
- super(YangStmtMapping.MANDATORY);
+ super(YangStmtMapping.MANDATORY,
+ new EmptyMandatoryEffectiveStatement(new EmptyMandatoryStatement(Boolean.FALSE)),
+ new EmptyMandatoryEffectiveStatement(new EmptyMandatoryStatement(Boolean.TRUE)));
}
public static MandatoryStatementSupport getInstance() {
}
@Override
- public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return ArgumentUtils.parseBoolean(ctx, value);
- }
-
- @Override
- public MandatoryStatement createDeclared(final StmtContext<Boolean, MandatoryStatement, ?> ctx) {
- final MandatoryStatement ret = new MandatoryStatementImpl(ctx);
- if (EmptyMandatoryStatement.FALSE.equals(ret)) {
- return EmptyMandatoryStatement.FALSE;
- } else if (EmptyMandatoryStatement.TRUE.equals(ret)) {
- return EmptyMandatoryStatement.TRUE;
- } else {
- return ret;
- }
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
@Override
- public EffectiveStatement<Boolean, MandatoryStatement> createEffective(
- final StmtContext<Boolean, MandatoryStatement, EffectiveStatement<Boolean, MandatoryStatement>> ctx) {
- final EffectiveStatement<Boolean, MandatoryStatement> ret = new MandatoryEffectiveStatementImpl(ctx);
- final MandatoryStatement declared = ret.getDeclared();
- if (declared instanceof EmptyMandatoryStatement && ret.effectiveSubstatements().isEmpty()) {
- return ((EmptyMandatoryStatement)declared).toEffective();
- }
- return ret;
+ protected MandatoryStatement createDeclared(final StmtContext<Boolean, MandatoryStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularMandatoryStatement(ctx.coerceStatementArgument(), substatements);
}
@Override
- public String internArgument(final String rawArgument) {
- return ArgumentUtils.internBoolean(rawArgument);
+ protected MandatoryEffectiveStatement createEffective(
+ final StmtContext<Boolean, MandatoryStatement, MandatoryEffectiveStatement> ctx,
+ final MandatoryStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new RegularMandatoryEffectiveStatement(declared, substatements);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected MandatoryEffectiveStatement createEmptyEffective(final MandatoryStatement declared) {
+ return new EmptyMandatoryEffectiveStatement(declared);
}
-}
\ No newline at end of file
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.mandatory;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+
+final class RegularMandatoryEffectiveStatement extends AbstractMandatoryEffectiveStatement {
+ private final @NonNull Object substatements;
+
+ RegularMandatoryEffectiveStatement(final MandatoryStatement declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(declared);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+ return unmaskList(substatements);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.mandatory;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularMandatoryStatement extends AbstractMandatoryStatement {
+ private final @NonNull Object substatements;
+
+ RegularMandatoryStatement(final Boolean argument,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ super(argument);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+ return unmaskList(substatements);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt.require_instance;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
+
+abstract class AbstractRequireInstanceEffectiveStatement
+ extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, RequireInstanceStatement>
+ implements RequireInstanceEffectiveStatement {
+ AbstractRequireInstanceEffectiveStatement(final RequireInstanceStatement declared) {
+ super(declared);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt.require_instance;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractRequireInstanceStatement extends AbstractBooleanDeclaredStatement
+ implements RequireInstanceStatement {
+ AbstractRequireInstanceStatement(final Boolean argument) {
+ super(argument);
+ }
+
+ @Override
+ public StatementDefinition statementDefinition() {
+ return YangStmtMapping.REQUIRE_INSTANCE;
+ }
+}
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.require_instance;
import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-final class RequireInstanceStatementImpl extends AbstractDeclaredStatement<Boolean>
- implements RequireInstanceStatement {
- RequireInstanceStatementImpl(final StmtContext<Boolean, RequireInstanceStatement, ?> context) {
- super(context);
+final class EmptyRequireInstanceEffectiveStatement extends AbstractRequireInstanceEffectiveStatement {
+ EmptyRequireInstanceEffectiveStatement(final RequireInstanceStatement declared) {
+ super(declared);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.require_instance;
+
+final class EmptyRequireInstanceStatement extends AbstractRequireInstanceStatement {
+ EmptyRequireInstanceStatement(final Boolean argument) {
+ super(argument);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.require_instance;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+
+final class RegularRequireInstanceEffectiveStatement extends AbstractRequireInstanceEffectiveStatement {
+ private final @NonNull Object substatements;
+
+ RegularRequireInstanceEffectiveStatement(final RequireInstanceStatement declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(declared);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+ return unmaskList(substatements);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.require_instance;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularRequireInstanceStatement extends AbstractRequireInstanceStatement {
+ private final @NonNull Object substatements;
+
+ RegularRequireInstanceStatement(final Boolean argument,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ super(argument);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+ return unmaskList(substatements);
+ }
+}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.require_instance;
+import com.google.common.collect.ImmutableList;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.RequireInstanceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
public final class RequireInstanceStatementSupport
- extends AbstractStatementSupport<Boolean, RequireInstanceStatement, RequireInstanceEffectiveStatement> {
+ extends BaseBooleanStatementSupport<RequireInstanceStatement, RequireInstanceEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.REQUIRE_INSTANCE).build();
private static final RequireInstanceStatementSupport INSTANCE = new RequireInstanceStatementSupport();
+
private RequireInstanceStatementSupport() {
- super(YangStmtMapping.REQUIRE_INSTANCE);
+ super(YangStmtMapping.REQUIRE_INSTANCE,
+ new EmptyRequireInstanceEffectiveStatement(new EmptyRequireInstanceStatement(Boolean.FALSE)),
+ new EmptyRequireInstanceEffectiveStatement(new EmptyRequireInstanceStatement(Boolean.TRUE)));
}
public static RequireInstanceStatementSupport getInstance() {
}
@Override
- public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return ArgumentUtils.parseBoolean(ctx, value);
- }
-
- @Override
- public RequireInstanceStatement createDeclared(final StmtContext<Boolean, RequireInstanceStatement, ?> ctx) {
- return new RequireInstanceStatementImpl(ctx);
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
@Override
- public RequireInstanceEffectiveStatement createEffective(
- final StmtContext<Boolean, RequireInstanceStatement, RequireInstanceEffectiveStatement> ctx) {
- return new RequireInstanceEffectiveStatementImpl(ctx);
+ protected RequireInstanceStatement createDeclared(final StmtContext<Boolean, RequireInstanceStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularRequireInstanceStatement(ctx.coerceStatementArgument(), substatements);
}
@Override
- public String internArgument(final String rawArgument) {
- return ArgumentUtils.internBoolean(rawArgument);
+ protected RequireInstanceEffectiveStatement createEffective(
+ final StmtContext<Boolean, RequireInstanceStatement, RequireInstanceEffectiveStatement> ctx,
+ final RequireInstanceStatement declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new RegularRequireInstanceEffectiveStatement(declared, substatements);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected EmptyRequireInstanceEffectiveStatement createEmptyEffective(final RequireInstanceStatement declared) {
+ return new EmptyRequireInstanceEffectiveStatement(declared);
}
}
\ No newline at end of file
/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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,
import org.opendaylight.yangtools.yang.model.api.stmt.YinElementEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement;
-final class YinElementEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Boolean, YinElementStatement>
+abstract class AbstractYinElementEffectiveStatement
+ extends AbstractDeclaredEffectiveStatement.DefaultArgument<Boolean, YinElementStatement>
implements YinElementEffectiveStatement {
- YinElementEffectiveStatementImpl(final StmtContext<Boolean, YinElementStatement, ?> ctx) {
- super(ctx);
+ AbstractYinElementEffectiveStatement(final YinElementStatement declared) {
+ super(declared);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. 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.rfc7950.stmt.yin_element;
+
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractBooleanDeclaredStatement;
+
+abstract class AbstractYinElementStatement extends AbstractBooleanDeclaredStatement implements YinElementStatement {
+ AbstractYinElementStatement(final Boolean argument) {
+ super(argument);
+ }
+
+ @Override
+ public StatementDefinition statementDefinition() {
+ return YangStmtMapping.YIN_ELEMENT;
+ }
+}
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.yin_element;
import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-final class YinElementStatementImpl extends AbstractDeclaredStatement<Boolean> implements YinElementStatement {
- YinElementStatementImpl(final StmtContext<Boolean, YinElementStatement, ?> context) {
- super(context);
+final class EmptyYinElementEffectiveStatement extends AbstractYinElementEffectiveStatement {
+ EmptyYinElementEffectiveStatement(final YinElementStatement declared) {
+ super(declared);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.yin_element;
+
+final class EmptyYinElementStatement extends AbstractYinElementStatement {
+ EmptyYinElementStatement(final Boolean argument) {
+ super(argument);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.yin_element;
+
+import com.google.common.collect.ImmutableList;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
+
+final class RegularYinElementEffectiveStatement extends AbstractYinElementEffectiveStatement {
+ private final @NonNull Object substatements;
+
+ RegularYinElementEffectiveStatement(final YinElementStatement declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ super(declared);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public ImmutableList<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+ return unmaskList(substatements);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.rfc7950.stmt.yin_element;
+
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+final class RegularYinElementStatement extends AbstractYinElementStatement {
+ private final @NonNull Object substatements;
+
+ RegularYinElementStatement(final Boolean argument,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ super(argument);
+ this.substatements = maskList(substatements);
+ }
+
+ @Override
+ public Collection<? extends DeclaredStatement<?>> declaredSubstatements() {
+ return unmaskList(substatements);
+ }
+}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.yin_element;
+import com.google.common.collect.ImmutableList;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.YinElementEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseBooleanStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
public final class YinElementStatementSupport
- extends AbstractStatementSupport<Boolean, YinElementStatement, YinElementEffectiveStatement> {
+ extends BaseBooleanStatementSupport<YinElementStatement, YinElementEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.YIN_ELEMENT).build();
private static final YinElementStatementSupport INSTANCE = new YinElementStatementSupport();
private YinElementStatementSupport() {
- super(YangStmtMapping.YIN_ELEMENT);
+ super(YangStmtMapping.YIN_ELEMENT,
+ new EmptyYinElementEffectiveStatement(new EmptyYinElementStatement(Boolean.FALSE)),
+ new EmptyYinElementEffectiveStatement(new EmptyYinElementStatement(Boolean.TRUE)));
}
public static YinElementStatementSupport getInstance() {
}
@Override
- public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return ArgumentUtils.parseBoolean(ctx, value);
- }
-
- @Override
- public YinElementStatement createDeclared(final StmtContext<Boolean, YinElementStatement, ?> ctx) {
- return new YinElementStatementImpl(ctx);
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
@Override
- public YinElementEffectiveStatement createEffective(
- final StmtContext<Boolean, YinElementStatement, YinElementEffectiveStatement> ctx) {
- return new YinElementEffectiveStatementImpl(ctx);
+ protected YinElementStatement createDeclared(final StmtContext<Boolean, YinElementStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularYinElementStatement(ctx.coerceStatementArgument(), substatements);
}
@Override
- public String internArgument(final String rawArgument) {
- return ArgumentUtils.internBoolean(rawArgument);
+ protected YinElementEffectiveStatement createEffective(
+ final StmtContext<Boolean, YinElementStatement, YinElementEffectiveStatement> ctx,
+ final YinElementStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return new RegularYinElementEffectiveStatement(declared, substatements);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected YinElementEffectiveStatement createEmptyEffective(final YinElementStatement declared) {
+ return new EmptyYinElementEffectiveStatement(declared);
}
-}
\ No newline at end of file
+}