*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy;
-
-import com.google.common.collect.ImmutableSet;
+import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import com.google.common.collect.ImmutableSet;
+import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
-import java.util.Collection;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import com.google.common.base.Optional;
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.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+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.ContainerStatement;
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 ContainerEffectiveStatementImpl extends
AbstractEffectiveDocumentedDataNodeContainer<QName, ContainerStatement>
private final SchemaPath path;
private boolean presence;
- private boolean augmenting;
+ boolean augmenting;
private boolean addedByUses;
- private boolean configuration;
+ private boolean configuration = true;
private ContainerSchemaNode original;
private ConstraintDefinition constraints;
qname = ctx.getStatementArgument();
path = Utils.getSchemaPath(ctx);
+ this.constraints = new EffectiveConstraintDefinitionImpl(this);
initCopyType(ctx);
- initFields();
- // :TODO init other fields
+ initSubstatementCollectionsAndFields();
}
private void initCopyType(
StmtContext<QName, ContainerStatement, EffectiveStatement<QName, ContainerStatement>> 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;
+ }
+ if(copyTypesFromOriginal.contains(TypeOfCopy.ADDED_BY_USES_AUGMENTATION)) {
+ addedByUses = augmenting = true;
+ }
+
+ if (ctx.getOriginalCtx() != null) {
original = (ContainerSchemaNode) ctx.getOriginalCtx().buildEffective();
- break;
- default:
- break;
}
}
- private void initFields() {
+ private void initSubstatementCollectionsAndFields() {
Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
Set<AugmentationSchema> augmentationsInit = new HashSet<>();
+ boolean configurationInit = false;
for (EffectiveStatement<?, ?> effectiveSubstatement : effectiveSubstatements) {
if (effectiveSubstatement instanceof UnknownSchemaNode) {
UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveSubstatement;
if (effectiveSubstatement instanceof PresenceEffectiveStatementImpl) {
presence = true;
}
- if (effectiveSubstatement instanceof ConfigEffectiveStatementImpl) {
- ConfigEffectiveStatementImpl config = (ConfigEffectiveStatementImpl) effectiveSubstatement;
- this.configuration = config.argument();
+ if (!configurationInit
+ && effectiveSubstatement instanceof ConfigEffectiveStatementImpl) {
+ ConfigEffectiveStatementImpl configStmt = (ConfigEffectiveStatementImpl) effectiveSubstatement;
+ this.configuration = configStmt.argument();
+ configurationInit = true;
}
}
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;
}
public String toString() {
return "container " + qname.getLocalName();
}
-}
\ No newline at end of file
+}