*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
+import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QNameModule;
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.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.IncludedModuleContext;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
this.setRootIdentifier(identifier);
}
- RootStatementContext(final RootStatementContext<A, D, E> original, final QNameModule newQNameModule,
- final CopyType typeOfCopy) {
- super(original);
-
- sourceContext = Preconditions.checkNotNull(original.sourceContext);
- this.argument = original.argument;
-
- final Collection<StatementContextBase<?, ?, ?>> declared = original.declaredSubstatements();
- final Collection<StatementContextBase<?, ?, ?>> effective = original.effectiveSubstatements();
- final Collection<StatementContextBase<?, ?, ?>> buffer = new ArrayList<>(declared.size() + effective.size());
-
- for (final StatementContextBase<?, ?, ?> stmtContext : declared) {
- if (StmtContextUtils.areFeaturesSupported(stmtContext)) {
- buffer.add(stmtContext.createCopy(newQNameModule, this, typeOfCopy));
- }
- }
- for (final StmtContext<?, ?, ?> stmtContext : effective) {
- buffer.add(stmtContext.createCopy(newQNameModule, this, typeOfCopy));
- }
-
- addEffectiveSubstatements(buffer);
- }
-
/**
* @return null as root cannot have parent
*/
return argument;
}
- /**
- * @return copy of this considering {@link CopyType} (augment, uses)
- *
- * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException instance of SourceException
- */
@Override
- public StatementContextBase<?, ?, ?> createCopy(final StatementContextBase<?, ?, ?> newParent,
+ public StatementContextBase<A, D, E> createCopy(final StatementContextBase<?, ?, ?> newParent,
final CopyType typeOfCopy) {
- return createCopy(null, newParent, typeOfCopy);
+ throw new UnsupportedOperationException("Root context cannot be copied");
}
- /**
- * @return copy of this considering {@link CopyType} (augment, uses)
- *
- * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException instance of SourceException
- */
@Override
public StatementContextBase<A, D, E> createCopy(final QNameModule newQNameModule,
final StatementContextBase<?, ?, ?> newParent, final CopyType typeOfCopy) {
- final RootStatementContext<A, D, E> copy = new RootStatementContext<>(this, newQNameModule, typeOfCopy);
-
- copy.appendCopyHistory(typeOfCopy, this.getCopyHistory());
-
- if (this.getOriginalCtx() != null) {
- copy.setOriginalCtx(this.getOriginalCtx());
- } else {
- copy.setOriginalCtx(this);
- }
- definition().onStatementAdded(copy);
- return copy;
+ throw new UnsupportedOperationException("Root context cannot be copied");
}
@Nonnull
return Optional.of(SchemaPath.ROOT);
}
- /**
- * @return true
- */
- @Override
- public boolean isRootContext() {
- return true;
- }
-
@Override
public boolean isConfiguration() {
return true;