-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
-public class UsesEffectiveStatementImpl extends EffectiveStatementBase<QName, UsesStatement> implements UsesNode {
- private SchemaPath groupingPath;
- private boolean addedByUses;
- private ImmutableMap<SchemaPath, SchemaNode> refines;
- private ImmutableSet<AugmentationSchema> augmentations;
- private ImmutableList<UnknownSchemaNode> unknownNodes;
+public final class UsesEffectiveStatementImpl extends EffectiveStatementBase<QName, UsesStatement> implements UsesNode {
+ private final SchemaPath groupingPath;
+ private final boolean addedByUses;
+ private final Map<SchemaPath, SchemaNode> refines;
+ private final Set<AugmentationSchema> augmentations;
+ private final List<UnknownSchemaNode> unknownNodes;
- public UsesEffectiveStatementImpl(final StmtContext<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> ctx) {
+ public UsesEffectiveStatementImpl(
+ final StmtContext<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> ctx) {
super(ctx);
- initGroupingPath(ctx);
- initCopyType(ctx);
- initSubstatementCollections();
- }
-
- private void initGroupingPath(final StmtContext<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> ctx) {
+ // initGroupingPath
StmtContext<?, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> grpCtx = ctx.getFromNamespace(
GroupingNamespace.class, ctx.getStatementArgument());
this.groupingPath = Utils.getSchemaPath(grpCtx);
- }
- private void initSubstatementCollections() {
- Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+ // initCopyType
+ List<TypeOfCopy> copyTypesFromOriginal = ctx.getCopyHistory();
+ if (copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) {
+ addedByUses = true;
+ } else {
+ addedByUses = false;
+ }
+ // initSubstatementCollections
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
Set<AugmentationSchema> augmentationsInit = new HashSet<>();
Map<SchemaPath, SchemaNode> refinesInit = new HashMap<>();
-
for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
if (effectiveStatement instanceof UnknownSchemaNode) {
UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
refinesInit.put(identifier.asSchemaPath(), refineStmt.getRefineTargetNode());
}
}
-
this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
this.augmentations = ImmutableSet.copyOf(augmentationsInit);
this.refines = ImmutableMap.copyOf(refinesInit);
}
- private void initCopyType(
- final StmtContext<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> ctx) {
-
- List<TypeOfCopy> copyTypesFromOriginal = ctx.getCopyHistory();
- if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) {
- addedByUses = true;
- }
- }
-
@Override
public SchemaPath getGroupingPath() {
return groupingPath;
return addedByUses;
}
- void setAddedByUses(final boolean addedByUses) {
- this.addedByUses = addedByUses;
- }
-
@Override
public Map<SchemaPath, SchemaNode> getRefines() {
return refines;