*/
package org.opendaylight.yangtools.yang.parser.builder.impl;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.YangNode;
import org.opendaylight.yangtools.yang.parser.builder.api.AbstractTypeAwareBuilder;
import org.opendaylight.yangtools.yang.parser.builder.api.DataSchemaNodeBuilder;
-import org.opendaylight.yangtools.yang.parser.builder.api.GroupingMember;
import org.opendaylight.yangtools.yang.parser.util.Comparators;
-public final class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder implements DataSchemaNodeBuilder,
- GroupingMember {
+public final class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder implements DataSchemaNodeBuilder {
private boolean isBuilt;
private final LeafListSchemaNodeImpl instance;
// SchemaNode args
constraints = new ConstraintsBuilder(moduleName, line);
}
- public LeafListSchemaNodeBuilder(final LeafListSchemaNodeBuilder b, final QName qname) {
- super(b.getModuleName(), b.getLine(), qname);
- instance = new LeafListSchemaNodeImpl(qname);
-
- type = b.getType();
- typedef = b.getTypedef();
-
- constraints = new ConstraintsBuilder(b.getConstraints());
- schemaPath = b.getPath();
- description = b.getDescription();
- reference = b.getReference();
- status = b.getStatus();
- augmenting = b.isAugmenting();
- addedByUses = b.isAddedByUses();
- configuration = b.isConfiguration();
- userOrdered = b.isUserOrdered();
- unknownNodes = b.unknownNodes;
- addedUnknownNodes.addAll(b.getUnknownNodeBuilders());
- }
-
@Override
- public LeafListSchemaNode build() {
+ public LeafListSchemaNode build(YangNode parent) {
if (!isBuilt) {
+ instance.setParent(parent);
instance.setConstraints(constraints.build());
instance.setPath(schemaPath);
instance.setDescription(description);
instance.setUserOrdered(userOrdered);
if (type == null) {
- instance.setType(typedef.build());
+ instance.setType(typedef.build(instance));
} else {
instance.setType(type);
}
// UNKNOWN NODES
- if (unknownNodes == null) {
- unknownNodes = new ArrayList<UnknownSchemaNode>();
- for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
- unknownNodes.add(b.build());
- }
- Collections.sort(unknownNodes, Comparators.SCHEMA_NODE_COMP);
+ for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+ unknownNodes.add(b.build(instance));
}
+ Collections.sort(unknownNodes, Comparators.SCHEMA_NODE_COMP);
instance.setUnknownSchemaNodes(unknownNodes);
isBuilt = true;
return instance;
}
+ @Override
+ public void setQName(QName qname) {
+ this.qname = qname;
+ instance.setQName(qname);
+ }
+
+ @Override
public SchemaPath getPath() {
return schemaPath;
}
this.schemaPath = schemaPath;
}
+ @Override
public String getDescription() {
return description;
}
this.description = description;
}
+ @Override
public String getReference() {
return reference;
}
this.reference = reference;
}
+ @Override
public Status getStatus() {
return status;
}
}
}
+ @Override
public boolean isAugmenting() {
return augmenting;
}
this.addedByUses = addedByUses;
}
+ @Override
public Boolean isConfiguration() {
return configuration;
}
} else if (!schemaPath.equals(other.schemaPath)) {
return false;
}
- if (parent == null) {
- if (other.parent != null) {
+ if (parentBuilder == null) {
+ if (other.parentBuilder != null) {
return false;
}
- } else if (!parent.equals(other.parent)) {
+ } else if (!parentBuilder.equals(other.parentBuilder)) {
return false;
}
return true;
}
private final class LeafListSchemaNodeImpl implements LeafListSchemaNode {
- private final QName qname;
+ private QName qname;
private SchemaPath path;
+ private YangNode parent;
private String description;
private String reference;
private Status status = Status.CURRENT;
return qname;
}
+ private void setQName(QName qname) {
+ this.qname = qname;
+ }
+
@Override
public SchemaPath getPath() {
return path;
this.path = path;
}
+ @Override
+ public YangNode getParent() {
+ return parent;
+ }
+
+ private void setParent(YangNode parent) {
+ this.parent = parent;
+ }
+
@Override
public String getDescription() {
return description;