+ @Override
+ public boolean isConfiguration() {
+ return true;
+ }
+
+ @Override
+ public boolean isEnabledSemanticVersioning() {
+ return sourceContext.isEnabledSemanticVersioning();
+ }
+
+ @Override
+ public <K, V, N extends IdentifierNamespace<K, V>> void addToLocalStorage(final Class<N> type, final K key,
+ final V value) {
+ if (IncludedModuleContext.class.isAssignableFrom(type)) {
+ if (includedContexts.isEmpty()) {
+ includedContexts = new ArrayList<>(1);
+ }
+ Verify.verify(value instanceof RootStatementContext);
+ includedContexts.add((RootStatementContext<?, ?, ?>) value);
+ }
+ super.addToLocalStorage(type, key, value);
+ }
+
+ @Override
+ public <K, V, N extends IdentifierNamespace<K, V>> V getFromLocalStorage(final Class<N> type, final K key) {
+ final V potentialLocal = super.getFromLocalStorage(type, key);
+ if (potentialLocal != null) {
+ return potentialLocal;
+ }
+ for (final NamespaceStorageNode includedSource : includedContexts) {
+ final V potential = includedSource.getFromLocalStorage(type, key);
+ if (potential != null) {
+ return potential;
+ }
+ }
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromLocalStorage(final Class<N> type) {
+ final Map<K, V> potentialLocal = super.getAllFromLocalStorage(type);
+ if (potentialLocal != null) {
+ return potentialLocal;
+ }
+ for (final NamespaceStorageNode includedSource : includedContexts) {
+ final Map<K, V> potential = includedSource.getAllFromLocalStorage(type);
+ if (potential != null) {
+ return potential;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public YangVersion getRootVersion() {
+ return version == null ? DEFAULT_VERSION : version;
+ }
+
+ @Override
+ public void setRootVersion(final YangVersion version) {
+ Preconditions.checkArgument(sourceContext.getSupportedVersions().contains(version),
+ "Unsupported yang version %s in %s", version, getStatementSourceReference());
+ Preconditions.checkState(this.version == null, "Version of root %s has been already set to %s", argument,
+ this.version);
+ this.version = Preconditions.checkNotNull(version);
+ }