X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-rfc7950%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Frfc7950%2Fstmt%2FAbstractEffectiveDocumentedDataNodeContainer.java;h=c13fc5bc65957ce246a0074a6410d8b5a746fa27;hb=bb0e490b6873241efe905cab2dbd429991daf24b;hp=84b32691c8c7f0b67199fc8281235e0d9723ea11;hpb=679a3b2027fd416dc3a19ec602dffa42cb680767;p=yangtools.git
diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveDocumentedDataNodeContainer.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveDocumentedDataNodeContainer.java
index 84b32691c8..c13fc5bc65 100644
--- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveDocumentedDataNodeContainer.java
+++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveDocumentedDataNodeContainer.java
@@ -7,20 +7,13 @@
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
+import java.util.Collection;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
-import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
@@ -29,15 +22,11 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.YangValidationBundles;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.choice.ImplicitCaseSchemaNode;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.source.AugmentToChoiceNamespace;
public abstract class AbstractEffectiveDocumentedDataNodeContainer>
extends AbstractSchemaEffectiveDocumentedNode implements DataNodeContainer {
- private final ImmutableMap childNodes;
private final ImmutableSet groupings;
private final ImmutableSet uses;
private final ImmutableSet> typeDefinitions;
@@ -46,7 +35,6 @@ public abstract class AbstractEffectiveDocumentedDataNodeContainer ctx) {
super(ctx);
- Map mutableChildNodes = new LinkedHashMap<>();
Set mutableGroupings = new HashSet<>();
Set mutableUses = new HashSet<>();
Set> mutableTypeDefinitions = new LinkedHashSet<>();
@@ -54,52 +42,20 @@ public abstract class AbstractEffectiveDocumentedDataNodeContainer stmt : effectiveSubstatements()) {
if (stmt instanceof DataSchemaNode) {
- final DataSchemaNode dataSchemaNode = (DataSchemaNode) stmt;
- if (mutableChildNodes.containsKey(dataSchemaNode.getQName())) {
- throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
- }
-
- // Add case short hand when augmenting choice with short hand
- if (this instanceof AugmentationSchemaNode
- && !(stmt instanceof CaseSchemaNode || stmt instanceof ChoiceSchemaNode)
- && YangValidationBundles.SUPPORTED_CASE_SHORTHANDS.contains(stmt.statementDefinition())
- && Boolean.TRUE.equals(ctx.getFromNamespace(AugmentToChoiceNamespace.class, ctx))) {
- final ImplicitCaseSchemaNode caseShorthand = new ImplicitCaseSchemaNode(dataSchemaNode);
- mutableChildNodes.put(caseShorthand.getQName(), caseShorthand);
- mutablePublicChildNodes.add(caseShorthand);
- } else {
- mutableChildNodes.put(dataSchemaNode.getQName(), dataSchemaNode);
- mutablePublicChildNodes.add(dataSchemaNode);
- }
+ mutablePublicChildNodes.add((DataSchemaNode) stmt);
}
- if (stmt instanceof UsesNode) {
- UsesNode usesNode = (UsesNode) stmt;
- if (!mutableUses.contains(usesNode)) {
- mutableUses.add(usesNode);
- } else {
- throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
- }
+ if (stmt instanceof UsesNode && !mutableUses.add((UsesNode) stmt)) {
+ throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
}
- if (stmt instanceof TypedefEffectiveStatement) {
- TypedefEffectiveStatement typeDef = (TypedefEffectiveStatement) stmt;
- TypeDefinition> type = typeDef.getTypeDefinition();
- if (!mutableTypeDefinitions.contains(type)) {
- mutableTypeDefinitions.add(type);
- } else {
- throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
- }
+ if (stmt instanceof TypedefEffectiveStatement
+ && !mutableTypeDefinitions.add(((TypedefEffectiveStatement) stmt).getTypeDefinition())) {
+ throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
}
- if (stmt instanceof GroupingDefinition) {
- GroupingDefinition grp = (GroupingDefinition) stmt;
- if (!mutableGroupings.contains(grp)) {
- mutableGroupings.add(grp);
- } else {
- throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
- }
+ if (stmt instanceof GroupingDefinition && !mutableGroupings.add((GroupingDefinition) stmt)) {
+ throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
}
}
- this.childNodes = ImmutableMap.copyOf(mutableChildNodes);
this.groupings = ImmutableSet.copyOf(mutableGroupings);
this.publicChildNodes = ImmutableSet.copyOf(mutablePublicChildNodes);
this.typeDefinitions = ImmutableSet.copyOf(mutableTypeDefinitions);
@@ -107,12 +63,12 @@ public abstract class AbstractEffectiveDocumentedDataNodeContainer> getTypeDefinitions() {
+ public final Collection extends TypeDefinition>> getTypeDefinitions() {
return typeDefinitions;
}
@Override
- public final Set getChildNodes() {
+ public final Collection extends DataSchemaNode> getChildNodes() {
return publicChildNodes;
}
@@ -123,8 +79,7 @@ public abstract class AbstractEffectiveDocumentedDataNodeContainer findDataChildByName(final QName name) {
- // Child nodes are keyed by their container name, so we can do a direct lookup
- return Optional.ofNullable(childNodes.get(requireNonNull(name)));
+ return findDataSchemaNode(name);
}
@Override