*/
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;
boolean augmenting;
boolean addedByUses;
- boolean configuration;
+ boolean configuration = true;
ContainerSchemaNode original;
ConstraintDefinition constraints;
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<QName, InputStatement, EffectiveStatement<QName, InputStatement>> ctx) {
+
+ List<TypeOfCopy> 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<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
Set<AugmentationSchema> augmentationsInit = new HashSet<>();
+ boolean configurationInit = false;
for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
if (effectiveStatement instanceof UnknownSchemaNode) {
UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
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);