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%2Frfc6020%2Feffective%2FInputEffectiveStatementImpl.java;h=6757ba567e9d2fbe344e5b053277964218a3d5cc;hb=4f21e224aa1f39cf17df23b3f893e3d247122ec5;hp=e0ded9ec84b9068079599de01bac77927d4aec3b;hpb=40cc734f65f305ecb2d5d7e01b694e5e54f716e1;p=yangtools.git diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java index e0ded9ec84..6757ba567e 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/InputEffectiveStatementImpl.java @@ -7,10 +7,10 @@ */ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective; +import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy; import java.util.HashSet; import java.util.LinkedList; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils; - import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import java.util.List; @@ -36,7 +36,7 @@ public class InputEffectiveStatementImpl extends boolean augmenting; boolean addedByUses; - boolean configuration; + boolean configuration = true; ContainerSchemaNode original; ConstraintDefinition constraints; @@ -51,17 +51,39 @@ public class InputEffectiveStatementImpl extends path = Utils.getSchemaPath(ctx); presence = (firstEffective(PresenceEffectiveStatementImpl.class) == null) ? false : true; - // :TODO init other fields + this.constraints = new EffectiveConstraintDefinitionImpl(this); + + initSubstatementCollectionsAndFields(); + initCopyType(ctx); + } + + private void initCopyType( + StmtContext> ctx) { + + List copyTypesFromOriginal = ctx.getCopyHistory(); - initSubstatementCollections(); + if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) { + augmenting = true; + } + if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) { + addedByUses = true; + } + if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) { + addedByUses = augmenting = true; + } + + if (ctx.getOriginalCtx() != null) { + original = (ContainerSchemaNode) ctx.getOriginalCtx().buildEffective(); + } } - private void initSubstatementCollections() { + private void initSubstatementCollectionsAndFields() { Collection> effectiveSubstatements = effectiveSubstatements(); List unknownNodesInit = new LinkedList<>(); Set augmentationsInit = new HashSet<>(); + boolean configurationInit = false; for (EffectiveStatement effectiveStatement : effectiveSubstatements) { if (effectiveStatement instanceof UnknownSchemaNode) { UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement; @@ -71,6 +93,12 @@ public class InputEffectiveStatementImpl extends AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement; augmentationsInit.add(augmentationSchema); } + if (!configurationInit + && effectiveStatement instanceof ConfigEffectiveStatementImpl) { + ConfigEffectiveStatementImpl configStmt = (ConfigEffectiveStatementImpl) effectiveStatement; + this.configuration = configStmt.argument(); + configurationInit = true; + } } this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);