X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-reactor%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FRootStatementContext.java;h=e9089250d6d065786606111a1ed9ff46ffe1ecf1;hb=abc01c9a2e43ada97dfd003066848a63e958d3b1;hp=ab5b9f9348933b59369c1d5f4e3a22a3b60948ea;hpb=19efe56f8f20f5692a100e765a581fbc8f0b4aca;p=yangtools.git
diff --git a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
index ab5b9f9348..e9089250d6 100644
--- a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
+++ b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
@@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.YangVersion;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@@ -33,6 +34,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.MutableStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
+import org.opendaylight.yangtools.yang.parser.spi.meta.RootStmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.IncludedModuleContext;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
@@ -40,12 +42,12 @@ import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReferenc
* Root statement class for a YANG source. All statements defined in that YANG source are mapped underneath an instance
* of this class, hence recursive lookups from them cross this class.
*/
-public class RootStatementContext, E extends EffectiveStatement> extends
- StatementContextBase {
+public final class RootStatementContext, E extends EffectiveStatement>
+ extends AbstractResumedStatement implements RootStmtContext.Mutable {
public static final YangVersion DEFAULT_VERSION = YangVersion.VERSION_1;
- private final SourceSpecificContext sourceContext;
+ private final @NonNull SourceSpecificContext sourceContext;
private final A argument;
private YangVersion rootVersion;
@@ -84,11 +86,6 @@ public class RootStatementContext, E extends E
return sourceContext;
}
- @Override
- public Registry getBehaviourRegistry() {
- return sourceContext;
- }
-
@Override
public StorageNodeType getStorageNodeType() {
return StorageNodeType.ROOT_STATEMENT_LOCAL;
@@ -110,6 +107,7 @@ public class RootStatementContext, E extends E
}
@Override
+ @Deprecated
public Optional getSchemaPath() {
return Optional.of(SchemaPath.ROOT);
}
@@ -119,11 +117,6 @@ public class RootStatementContext, E extends E
return true;
}
- @Override
- public boolean isEnabledSemanticVersioning() {
- return sourceContext.isEnabledSemanticVersioning();
- }
-
@Override
public > V putToLocalStorage(final Class type, final K key,
final V value) {
@@ -195,35 +188,6 @@ public class RootStatementContext, E extends E
return null;
}
- @Override
- public YangVersion getRootVersion() {
- return rootVersion == null ? DEFAULT_VERSION : rootVersion;
- }
-
- @Override
- public void setRootVersion(final YangVersion version) {
- checkArgument(sourceContext.getSupportedVersions().contains(version),
- "Unsupported yang version %s in %s", version, getStatementSourceReference());
- checkState(this.rootVersion == null, "Version of root %s has been already set to %s", argument,
- this.rootVersion);
- this.rootVersion = requireNonNull(version);
- }
-
- @Override
- public void addMutableStmtToSeal(final MutableStatement mutableStatement) {
- sourceContext.addMutableStmtToSeal(mutableStatement);
- }
-
- @Override
- public void addRequiredSource(final SourceIdentifier dependency) {
- checkState(sourceContext.getInProgressPhase() == ModelProcessingPhase.SOURCE_PRE_LINKAGE,
- "Add required module is allowed only in ModelProcessingPhase.SOURCE_PRE_LINKAGE phase");
- if (requiredSources.isEmpty()) {
- requiredSources = new HashSet<>();
- }
- requiredSources.add(dependency);
- }
-
/**
* Return the set of required sources.
*
@@ -233,11 +197,6 @@ public class RootStatementContext, E extends E
return ImmutableSet.copyOf(requiredSources);
}
- @Override
- public void setRootIdentifier(final SourceIdentifier identifier) {
- this.rootIdentifier = requireNonNull(identifier);
- }
-
SourceIdentifier getRootIdentifier() {
return rootIdentifier;
}
@@ -256,4 +215,46 @@ public class RootStatementContext, E extends E
protected boolean isParentSupportedByFeatures() {
return true;
}
+
+ void setRootIdentifierImpl(final SourceIdentifier identifier) {
+ this.rootIdentifier = requireNonNull(identifier);
+ }
+
+ @NonNull Registry getBehaviourRegistryImpl() {
+ return sourceContext;
+ }
+
+ boolean isEnabledSemanticVersioningImpl() {
+ return sourceContext.globalContext().isEnabledSemanticVersioning();
+ }
+
+ @NonNull YangVersion getRootVersionImpl() {
+ return rootVersion == null ? DEFAULT_VERSION : rootVersion;
+ }
+
+ void setRootVersionImpl(final YangVersion version) {
+ checkArgument(sourceContext.globalContext().getSupportedVersions().contains(version),
+ "Unsupported yang version %s in %s", version, getStatementSourceReference());
+ checkState(this.rootVersion == null, "Version of root %s has been already set to %s", argument,
+ this.rootVersion);
+ this.rootVersion = requireNonNull(version);
+ }
+
+ void addMutableStmtToSealImpl(final MutableStatement mutableStatement) {
+ sourceContext.globalContext().addMutableStmtToSeal(mutableStatement);
+ }
+
+ void addRequiredSourceImpl(final SourceIdentifier dependency) {
+ checkState(sourceContext.getInProgressPhase() == ModelProcessingPhase.SOURCE_PRE_LINKAGE,
+ "Add required module is allowed only in ModelProcessingPhase.SOURCE_PRE_LINKAGE phase");
+ if (requiredSources.isEmpty()) {
+ requiredSources = new HashSet<>();
+ }
+ requiredSources.add(dependency);
+ }
+
+ @Override
+ StatementContextBase reparent(final StatementContextBase, ?, ?> newParent) {
+ throw new UnsupportedOperationException("Root statement cannot be reparented to" + newParent);
+ }
}