Add a missing space
[yangtools.git] / yang / yang-parser-reactor / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / RootStatementContext.java
index 11f6f921e9eefac2ba2f0a625518e79f96c14d58..99f2ab6a30d2bd2c576f0c535709a69a99285f71 100644 (file)
@@ -21,8 +21,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+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;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
@@ -42,11 +42,11 @@ import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReferenc
  * of this class, hence recursive lookups from them cross this class.
  */
 public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> extends
-        StatementContextBase<A, D, E> {
+        AbstractResumedStatement<A, D, E> {
 
     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;
@@ -85,17 +85,11 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
         return sourceContext;
     }
 
-    @Override
-    public Registry getBehaviourRegistry() {
-        return sourceContext;
-    }
-
     @Override
     public StorageNodeType getStorageNodeType() {
         return StorageNodeType.ROOT_STATEMENT_LOCAL;
     }
 
-    @Nonnull
     @Override
     public RootStatementContext<?, ?, ?> getRoot() {
         // this as its own root
@@ -111,8 +105,8 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
         return argument;
     }
 
-    @Nonnull
     @Override
+    @Deprecated
     public Optional<SchemaPath> getSchemaPath() {
         return Optional.of(SchemaPath.ROOT);
     }
@@ -122,11 +116,6 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
         return true;
     }
 
-    @Override
-    public boolean isEnabledSemanticVersioning() {
-        return sourceContext.isEnabledSemanticVersioning();
-    }
-
     @Override
     public <K, V, N extends IdentifierNamespace<K, V>> V putToLocalStorage(final Class<N> type, final K key,
             final V value) {
@@ -140,7 +129,6 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
         return super.putToLocalStorage(type, key, value);
     }
 
-    @Nullable
     @Override
     public <K, V, N extends IdentifierNamespace<K, V>> V getFromLocalStorage(final Class<N> type, final K key) {
         return getFromLocalStorage(type, key, new HashSet<>());
@@ -150,9 +138,8 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
      * We need to track already checked RootStatementContexts due to possible
      * circular chains of includes between submodules
      */
-    @Nullable
-    private <K, V, N extends IdentifierNamespace<K, V>> V getFromLocalStorage(final Class<N> type, final K key,
-            final HashSet<RootStatementContext<?, ?, ?>> alreadyChecked) {
+    private <K, V, N extends IdentifierNamespace<K, V>> @Nullable V getFromLocalStorage(final Class<N> type,
+            final K key, final HashSet<RootStatementContext<?, ?, ?>> alreadyChecked) {
         final V potentialLocal = super.getFromLocalStorage(type, key);
         if (potentialLocal != null) {
             return potentialLocal;
@@ -171,7 +158,6 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
         return null;
     }
 
-    @Nullable
     @Override
     public <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromLocalStorage(final Class<N> type) {
         return getAllFromLocalStorage(type, new HashSet<>());
@@ -181,8 +167,7 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
      * We need to track already checked RootStatementContexts due to possible
      * circular chains of includes between submodules
      */
-    @Nullable
-    private <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromLocalStorage(final Class<N> type,
+    private <K, V, N extends IdentifierNamespace<K, V>> @Nullable Map<K, V> getAllFromLocalStorage(final Class<N> type,
             final HashSet<RootStatementContext<?, ?, ?>> alreadyChecked) {
         final Map<K, V> potentialLocal = super.getAllFromLocalStorage(type);
         if (potentialLocal != null) {
@@ -202,35 +187,6 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, 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.
      *
@@ -240,11 +196,6 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
         return ImmutableSet.copyOf(requiredSources);
     }
 
-    @Override
-    public void setRootIdentifier(final SourceIdentifier identifier) {
-        this.rootIdentifier = requireNonNull(identifier);
-    }
-
     SourceIdentifier getRootIdentifier() {
         return rootIdentifier;
     }
@@ -263,4 +214,46 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, 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<A, D, E> reparent(final StatementContextBase<?, ?, ?> newParent) {
+        throw new UnsupportedOperationException("Root statement cannot be reparented to " + newParent);
+    }
 }