X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FRootStatementContext.java;h=6b876c71f607d7f215d0aef2cbad582b2f521aec;hb=30c67c4d780e897d972d60bb79d546b512516f90;hp=d32b8cdee123346d0b072c69ee56ed515ab61348;hpb=1f53275ab208027b01a60c697f576ce9fca7db22;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java index d32b8cdee1..6b876c71f6 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java @@ -7,34 +7,33 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.reactor; -import java.util.List; - +import java.util.Collection; import java.util.LinkedList; -import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import java.util.List; import org.opendaylight.yangtools.yang.common.QNameModule; -import java.util.Collection; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; 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.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; -class RootStatementContext, E extends EffectiveStatement> - extends StatementContextBase { +/** + * root statement class for a Yang source + */ +public class RootStatementContext, E extends EffectiveStatement> extends + StatementContextBase { private final SourceSpecificContext sourceContext; private final A argument; - RootStatementContext(ContextBuilder builder, - SourceSpecificContext sourceContext) throws SourceException { + RootStatementContext(ContextBuilder builder, SourceSpecificContext sourceContext) throws SourceException { super(builder); this.sourceContext = sourceContext; - this.argument = builder.getDefinition().parseArgumentValue(this, - builder.getRawArgument()); + this.argument = builder.getDefinition().parseArgumentValue(this, builder.getRawArgument()); } - RootStatementContext(RootStatementContext original, - QNameModule newQNameModule, TypeOfCopy typeOfCopy) + RootStatementContext(RootStatementContext original, QNameModule newQNameModule, TypeOfCopy typeOfCopy) throws SourceException { super(original); @@ -47,43 +46,63 @@ class RootStatementContext, E extends Effectiv } - private void copyDeclaredStmts(RootStatementContext original, - QNameModule newQNameModule, TypeOfCopy typeOfCopy) - throws SourceException { - Collection> originalDeclaredSubstatements = original - .declaredSubstatements(); + /** + * copies declared statements from original to this' substatements + * + * @param typeOfCopy + * determines whether copy is used by augmentation or uses + * @throws SourceException + */ + private void copyDeclaredStmts(RootStatementContext original, QNameModule newQNameModule, + TypeOfCopy typeOfCopy) throws SourceException { + Collection> originalDeclaredSubstatements = original.declaredSubstatements(); for (StmtContext stmtContext : originalDeclaredSubstatements) { - this.addEffectiveSubstatement(stmtContext.createCopy( - newQNameModule, this, typeOfCopy)); + this.addEffectiveSubstatement(stmtContext.createCopy(newQNameModule, this, typeOfCopy)); } } - private void copyEffectiveStmts(RootStatementContext original, - QNameModule newQNameModule, TypeOfCopy typeOfCopy) - throws SourceException { - Collection> originalEffectiveSubstatements = original - .effectiveSubstatements(); + /** + * copies effective statements from original to this' substatements + * + * @param typeOfCopy + * determines whether copy is used by augmentation or uses + * @throws SourceException + */ + private void copyEffectiveStmts(RootStatementContext original, QNameModule newQNameModule, + TypeOfCopy typeOfCopy) throws SourceException { + Collection> originalEffectiveSubstatements = original.effectiveSubstatements(); for (StmtContext stmtContext : originalEffectiveSubstatements) { - this.addEffectiveSubstatement(stmtContext.createCopy( - newQNameModule, this, typeOfCopy)); + this.addEffectiveSubstatement(stmtContext.createCopy(newQNameModule, this, typeOfCopy)); } } + /** + * @return null as root cannot have parent + */ @Override public StatementContextBase getParentContext() { return null; } + /** + * @return namespace storage of source context + */ @Override public NamespaceStorageNode getParentNamespaceStorage() { return sourceContext; } + /** + * @return registry of source context + */ @Override public Registry getBehaviourRegistry() { return sourceContext; } + /** + * @return this as its own root + */ @Override public RootStatementContext getRoot() { return this; @@ -98,26 +117,57 @@ class RootStatementContext, E extends Effectiv return argument; } + /** + * @return copy of this considering {@link TypeOfCopy} (augment, uses) + * + * @throws SourceException + */ @Override - public StatementContextBase createCopy(QNameModule newQNameModule, - StatementContextBase newParent, TypeOfCopy typeOfCopy) + public StatementContextBase createCopy(StatementContextBase newParent, TypeOfCopy typeOfCopy) throws SourceException { - RootStatementContext copy = new RootStatementContext<>(this, - newQNameModule, typeOfCopy); + return createCopy(null, newParent, typeOfCopy); + } + + /** + * @return copy of this considering {@link TypeOfCopy} (augment, uses) + * + * @throws SourceException + */ + @Override + public StatementContextBase createCopy(QNameModule newQNameModule, + StatementContextBase newParent, TypeOfCopy typeOfCopy) throws SourceException { + RootStatementContext copy = new RootStatementContext<>(this, newQNameModule, typeOfCopy); copy.setTypeOfCopy(typeOfCopy); copy.setOriginalCtx(this); return copy; } + /** + * @return this' argument as it is the only from root (this) + */ @Override public List getArgumentsFromRoot() { - List argumentList = new LinkedList(); + List argumentList = new LinkedList<>(); argumentList.add(argument); return argumentList; } + /** + * @return this as it is the only\context from root (this) + */ + @Override + public List> getStmtContextsFromRoot() { + List> stmtContextsList = new LinkedList<>(); + stmtContextsList.add(this); + return stmtContextsList; + } + + /** + * @return true + */ @Override public boolean isRootContext() { return true; } + }