*/
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.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import java.util.Collection;
-import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
public class InputEffectiveStatementImpl extends
AbstractEffectiveDocumentedDataNodeContainer<QName, InputStatement>
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);
- initSubstatementCollections();
+ initSubstatementCollectionsAndFields();
initCopyType(ctx);
}
private void initCopyType(
StmtContext<QName, InputStatement, EffectiveStatement<QName, InputStatement>> ctx) {
- TypeOfCopy typeOfCopy = ctx.getTypeOfCopy();
- switch (typeOfCopy) {
- case ADDED_BY_AUGMENTATION:
+ List<TypeOfCopy> copyTypesFromOriginal = ctx.getCopyHistory();
+
+ if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_AUGMENTATION)) {
augmenting = true;
- original = (ContainerSchemaNode) ctx.getOriginalCtx()
- .buildEffective();
- break;
- case ADDED_BY_USES:
+ }
+ if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES)) {
addedByUses = true;
- original = (ContainerSchemaNode) ctx.getOriginalCtx()
- .buildEffective();
- break;
- default:
- break;
+ }
+ 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);
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((qname == null) ? 0 : qname.hashCode());
- result = prime * result + ((path == null) ? 0 : path.hashCode());
+ result = prime * result + Objects.hashCode(qname);
+ result = prime * result + Objects.hashCode(path);
return result;
}