* This statement must appear as a top-level statement, otherwise it is ignored and does not appear in the final
* schema context. It must contain exactly one top-level container node (directly or indirectly via a uses statement).
*/
+// FIXME: 2.0.0: this interface should live in a separate RFC8040 API artifact.
@Beta
public interface YangDataSchemaNode extends UnknownSchemaNode {
/**
* Utility abstract base class for implementing declared statements.
*
- *
* @param <A> Argument type.
*/
public abstract class AbstractDeclaredStatement<A> implements DeclaredStatement<A> {
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AnyxmlSchemaLocationEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.OpenconfigVersionEffectiveStatementImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.YangDataEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc8040.YangDataEffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc8040.YangDataStatement;
@Beta
public enum SupportedExtensionsMapping implements StatementDefinition {
OPENCONFIG_VERSION("http://openconfig.net/yang/openconfig-ext",
OpenconfigVersionStatementImpl.class, OpenconfigVersionEffectiveStatementImpl.class,
"openconfig-version", "semver", false),
- YANG_DATA("urn:ietf:params:xml:ns:yang:ietf-restconf", "2017-01-26", YangDataStatementImpl.class,
- YangDataEffectiveStatementImpl.class, "yang-data", "name", true);
+ YANG_DATA("urn:ietf:params:xml:ns:yang:ietf-restconf", "2017-01-26", YangDataStatement.class,
+ YangDataEffectiveStatement.class, "yang-data", "name", true);
private final Class<? extends DeclaredStatement<?>> type;
private final Class<? extends EffectiveStatement<?, ?>> effectiveType;
+++ /dev/null
-/*
- * Copyright (c) 2017 Pantheon Technologies 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.stmt.rfc6020;
-
-import com.google.common.annotations.Beta;
-import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.YangDataEffectiveStatementImpl;
-
-/**
- * Declared statement representation of 'yang-data' extension defined in https://tools.ietf.org/html/rfc8040#section-8
- */
-@Beta
-public class YangDataStatementImpl extends AbstractDeclaredStatement<String> implements UnknownStatement<String> {
- private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
- SupportedExtensionsMapping.YANG_DATA)
- .addMandatory(YangStmtMapping.CONTAINER)
- .addOptional(YangStmtMapping.USES)
- .build();
-
- YangDataStatementImpl(final StmtContext<String, UnknownStatement<String>, ?> ctx) {
- super(ctx);
- }
-
- public static class YangDataSupport extends AbstractStatementSupport<String, UnknownStatement<String>,
- EffectiveStatement<String, UnknownStatement<String>>> {
-
- public YangDataSupport() {
- super(SupportedExtensionsMapping.YANG_DATA);
- }
-
- @Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
- }
-
- @Override
- public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return value;
- }
-
- @Override
- public UnknownStatement<String> createDeclared(final StmtContext<String, UnknownStatement<String>, ?> ctx) {
- return new YangDataStatementImpl(ctx);
- }
-
- @Override
- public EffectiveStatement<String, UnknownStatement<String>> createEffective(final StmtContext<String,
- UnknownStatement<String>, EffectiveStatement<String, UnknownStatement<String>>> ctx) {
- // in case of yang-data node we need to perform substatement validation at the point when we have
- // effective substatement contexts already available - if the node has only a uses statement declared in it,
- // one top-level container node may very well be added to the yang-data as an effective statement
- SUBSTATEMENT_VALIDATOR.validate(ctx);
- return new YangDataEffectiveStatementImpl(ctx);
- }
-
- @Override
- public void onFullDefinitionDeclared(final Mutable<String, UnknownStatement<String>,
- EffectiveStatement<String, UnknownStatement<String>>> ctx) {
- // as per https://tools.ietf.org/html/rfc8040#section-8,
- // yang-data is ignored unless it appears as a top-level statement
- if (ctx.getParentContext().getParentContext() != null) {
- ctx.setIsSupportedToBuildEffective(false);
- }
- }
-
- @Override
- public boolean isIgnoringIfFeatures() {
- return true;
- }
-
- @Override
- public boolean isIgnoringConfig() {
- return true;
- }
- }
-
- @Override
- public String getArgument() {
- return argument();
- }
-}
import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.RpcStatementRfc7950Support;
import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.SubmoduleStatementRfc7950Support;
import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.TypeStatementRfc7950Support;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc8040.YangDataStatementSupport;
public final class YangInferencePipeline {
public static final Set<YangVersion> SUPPORTED_VERSIONS = Sets.immutableEnumSet(VERSION_1, VERSION_1_1);
.addSupport(new ValueStatementImpl.Definition())
.addSupport(new AnyxmlSchemaLocationStatementImpl.AnyxmlSchemaLocationSupport())
.addSupport(treeScoped(AnyxmlSchemaLocationNamespace.class))
- .addSupport(new YangDataStatementImpl.YangDataSupport())
+ .addSupport(YangDataStatementSupport.getInstance())
.addSupport(global(StmtOrderingNamespace.class))
.build();
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+package org.opendaylight.yangtools.yang.parser.stmt.rfc8040;
import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContainerEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementBase;
/**
* Effective statement representation of 'yang-data' extension defined in https://tools.ietf.org/html/rfc8040#section-8
*/
@Beta
-public final class YangDataEffectiveStatementImpl extends UnknownEffectiveStatementBase<String>
+public final class YangDataEffectiveStatement extends UnknownEffectiveStatementBase<String>
implements YangDataSchemaNode {
private final SchemaPath path;
private final QName maybeQNameArgument;
private final ContainerSchemaNode containerSchemaNode;
- public YangDataEffectiveStatementImpl(final StmtContext<String, UnknownStatement<String>, ?> ctx) {
+ YangDataEffectiveStatement(final StmtContext<String, UnknownStatement<String>, ?> ctx) {
super(ctx);
QName maybeQNameArgumentInit;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
- if (!(obj instanceof YangDataEffectiveStatementImpl)) {
+ if (!(obj instanceof YangDataEffectiveStatement)) {
return false;
}
- final YangDataEffectiveStatementImpl other = (YangDataEffectiveStatementImpl) obj;
+ final YangDataEffectiveStatement other = (YangDataEffectiveStatement) obj;
return Objects.equals(maybeQNameArgument, other.maybeQNameArgument) && Objects.equals(path, other.path);
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies 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.stmt.rfc8040;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.SupportedExtensionsMapping;
+
+/**
+ * Declared statement representation of 'yang-data' extension defined in https://tools.ietf.org/html/rfc8040#section-8
+ */
+@Beta
+public final class YangDataStatement extends AbstractDeclaredStatement<String> implements UnknownStatement<String> {
+ static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
+ SupportedExtensionsMapping.YANG_DATA)
+ .addMandatory(YangStmtMapping.CONTAINER)
+ .addOptional(YangStmtMapping.USES)
+ .build();
+
+ YangDataStatement(final StmtContext<String, UnknownStatement<String>, ?> ctx) {
+ super(ctx);
+ }
+
+ @Override
+ public String getArgument() {
+ return argument();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies, 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.stmt.rfc8040;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.SupportedExtensionsMapping;
+
+@Beta
+public final class YangDataStatementSupport extends AbstractStatementSupport<String, UnknownStatement<String>,
+ EffectiveStatement<String, UnknownStatement<String>>> {
+ private static final YangDataStatementSupport INSTANCE = new YangDataStatementSupport();
+
+ private YangDataStatementSupport() {
+ super(SupportedExtensionsMapping.YANG_DATA);
+ }
+
+ public static YangDataStatementSupport getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ protected SubstatementValidator getSubstatementValidator() {
+ return YangDataStatement.SUBSTATEMENT_VALIDATOR;
+ }
+
+ @Override
+ public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ return value;
+ }
+
+ @Override
+ public UnknownStatement<String> createDeclared(final StmtContext<String, UnknownStatement<String>, ?> ctx) {
+ return new YangDataStatement(ctx);
+ }
+
+ @Override
+ public EffectiveStatement<String, UnknownStatement<String>> createEffective(final StmtContext<String,
+ UnknownStatement<String>, EffectiveStatement<String, UnknownStatement<String>>> ctx) {
+ // in case of yang-data node we need to perform substatement validation at the point when we have
+ // effective substatement contexts already available - if the node has only a uses statement declared in it,
+ // one top-level container node may very well be added to the yang-data as an effective statement
+ YangDataStatement.SUBSTATEMENT_VALIDATOR.validate(ctx);
+ return new YangDataEffectiveStatement(ctx);
+ }
+
+ @Override
+ public void onFullDefinitionDeclared(final Mutable<String, UnknownStatement<String>,
+ EffectiveStatement<String, UnknownStatement<String>>> ctx) {
+ // as per https://tools.ietf.org/html/rfc8040#section-8,
+ // yang-data is ignored unless it appears as a top-level statement
+ if (ctx.getParentContext().getParentContext() != null) {
+ ctx.setIsSupportedToBuildEffective(false);
+ }
+ }
+
+ @Override
+ public boolean isIgnoringIfFeatures() {
+ return true;
+ }
+
+ @Override
+ public boolean isIgnoringConfig() {
+ return true;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies, 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
+ */
+/**
+ * Support package for semantics defined in RFC8040, most notably yang-data statement.
+ */
+// FIXME: 2.0.0: this package should be an independent plugin
+package org.opendaylight.yangtools.yang.parser.stmt.rfc8040;
\ No newline at end of file