*/
package org.opendaylight.yangtools.yang.parser.builder.impl;
-import java.util.ArrayList;
-
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
* parent location
* @return copy of given builder
*/
- public static DataSchemaNodeBuilder copy(final DataSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
+ public static DataSchemaNodeBuilder copy(final DataSchemaNodeBuilder old, final Builder newParent,
+ final boolean updateQName) {
if (old instanceof AnyXmlBuilder) {
return copy((AnyXmlBuilder) old, newParent, updateQName);
} else if (old instanceof ChoiceBuilder) {
SchemaPath newSchemaPath = data.schemaPath;
AnyXmlBuilder copy = new AnyXmlBuilder(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
+ copy.setOriginal(old.getOriginal() == null ? old : old.getOriginal());
copyConstraints(copy.getConstraints(), old.getConstraints());
copy.setParent(newParent);
copy.setDescription(old.getDescription());
SchemaPath newSchemaPath = data.schemaPath;
ChoiceBuilder copy = new ChoiceBuilder(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
+ copy.setOriginal(old.getOriginal() == null ? old : old.getOriginal());
copyConstraints(copy.getConstraints(), old.getConstraints());
copy.setParent(newParent);
copy.setDescription(old.getDescription());
return copy;
}
- private static ChoiceCaseBuilder copy(final ChoiceCaseBuilder old, final Builder newParent, final boolean updateQName) {
+ private static ChoiceCaseBuilder copy(final ChoiceCaseBuilder old, final Builder newParent,
+ final boolean updateQName) {
DataBean data = getdata(old, newParent, updateQName);
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
- ChoiceCaseBuilder copy = new ChoiceCaseBuilder(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
+ ChoiceCaseBuilder copy = new ChoiceCaseBuilder(newParent.getModuleName(), newParent.getLine(), newQName,
+ newSchemaPath);
+ copy.setOriginal(old.getOriginal() == null ? old : old.getOriginal());
copyConstraints(copy.getConstraints(), old.getConstraints());
copy.setParent(newParent);
copy.setDescription(old.getDescription());
ContainerSchemaNodeBuilder copy = new ContainerSchemaNodeBuilder(newParent.getModuleName(),
newParent.getLine(), newQName, newSchemaPath);
+ copy.setOriginal(old.getOriginal() == null ? old : old.getOriginal());
copyConstraints(copy.getConstraints(), old.getConstraints());
copy.setParent(newParent);
copy.setDescription(old.getDescription());
return copy;
}
- private static LeafSchemaNodeBuilder copy(final LeafSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
+ private static LeafSchemaNodeBuilder copy(final LeafSchemaNodeBuilder old, final Builder newParent,
+ final boolean updateQName) {
DataBean data = getdata(old, newParent, updateQName);
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
LeafSchemaNodeBuilder copy = new LeafSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
newQName, newSchemaPath);
+ copy.setOriginal(old.getOriginal() == null ? old : old.getOriginal());
copyConstraints(copy.getConstraints(), old.getConstraints());
copy.setParent(newParent);
copy.setDescription(old.getDescription());
return copy;
}
- public static LeafListSchemaNodeBuilder copy(final LeafListSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
+ private static LeafListSchemaNodeBuilder copy(final LeafListSchemaNodeBuilder old, final Builder newParent,
+ final boolean updateQName) {
DataBean data = getdata(old, newParent, updateQName);
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
LeafListSchemaNodeBuilder copy = new LeafListSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
newQName, newSchemaPath);
+ copy.setOriginal(old.getOriginal() == null ? old : old.getOriginal());
copyConstraints(copy.getConstraints(), old.getConstraints());
copy.setParent(newParent);
copy.setDescription(old.getDescription());
return copy;
}
- private static ListSchemaNodeBuilder copy(final ListSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
+ private static ListSchemaNodeBuilder copy(final ListSchemaNodeBuilder old, final Builder newParent,
+ final boolean updateQName) {
DataBean data = getdata(old, newParent, updateQName);
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
ListSchemaNodeBuilder copy = new ListSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
newQName, newSchemaPath);
+ copy.setOriginal(old.getOriginal() == null ? old : old.getOriginal());
copyConstraints(copy.getConstraints(), old.getConstraints());
copy.setParent(newParent);
copy.setDescription(old.getDescription());
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
- GroupingBuilderImpl copy = new GroupingBuilderImpl(newParent.getModuleName(), newParent.getLine(), newQName, newSchemaPath);
+ GroupingBuilderImpl copy = new GroupingBuilderImpl(newParent.getModuleName(), newParent.getLine(), newQName,
+ newSchemaPath);
copy.setParent(newParent);
copy.setDescription(old.getDescription());
copy.setReference(old.getReference());
return copy;
}
- public static TypeDefinitionBuilder copy(final TypeDefinitionBuilder old, final Builder newParent, final boolean updateQName) {
+ public static TypeDefinitionBuilder copy(final TypeDefinitionBuilder old, final Builder newParent,
+ final boolean updateQName) {
DataBean data = getdata(old, newParent, updateQName);
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
return type;
}
- private static ConstraintsBuilder copyConstraints(final ConstraintsBuilder newConstraints, final ConstraintsBuilder old) {
+ private static ConstraintsBuilder copyConstraints(final ConstraintsBuilder newConstraints,
+ final ConstraintsBuilder old) {
newConstraints.getMustDefinitions().addAll(old.getMustDefinitions());
newConstraints.addWhenCondition(old.getWhenCondition());
newConstraints.setMandatory(old.isMandatory());
private static UsesNodeBuilder copyUses(final UsesNodeBuilder old, final Builder newParent) {
UsesNodeBuilder copy = new UsesNodeBuilderImpl(newParent.getModuleName(), newParent.getLine(),
- old.getGroupingPathAsString());
+ old.getGroupingPath());
copy.setParent(newParent);
copy.setGroupingDefinition(old.getGroupingDefinition());
copy.setGrouping(old.getGroupingBuilder());
private static AugmentationSchemaBuilder copyAugment(final AugmentationSchemaBuilder old, final Builder newParent) {
AugmentationSchemaBuilderImpl copy = new AugmentationSchemaBuilderImpl(newParent.getModuleName(),
- newParent.getLine(), old.getTargetPathAsString(), old.getOrder());
+ newParent.getLine(), old.getTargetPathAsString(), old.getTargetPath(), old.getOrder());
copy.setParent(newParent);
copy.setCopyOf(old);
copy.setDescription(old.getDescription());
copy.setReference(old.getReference());
copy.setStatus(old.getStatus());
copy.addWhenCondition(old.getWhenCondition());
- copy.setTargetNodeSchemaPath(old.getTargetNodeSchemaPath());
for (DataSchemaNodeBuilder childNode : old.getChildNodeBuilders()) {
copy.addChildNode(copy(childNode, copy, false));
}
return copy;
}
- public static UnknownSchemaNodeBuilderImpl copy(final UnknownSchemaNodeBuilder old, final Builder newParent, final boolean updateQName) {
+ public static UnknownSchemaNodeBuilderImpl copy(final UnknownSchemaNodeBuilder old, final Builder newParent,
+ final boolean updateQName) {
DataBean data = getdata(old, newParent, updateQName);
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
- UnknownSchemaNodeBuilderImpl c = new UnknownSchemaNodeBuilderImpl(newParent.getModuleName(), newParent.getLine(),
- newQName, newSchemaPath);
+ UnknownSchemaNodeBuilderImpl c = new UnknownSchemaNodeBuilderImpl(newParent.getModuleName(),
+ newParent.getLine(), newQName, newSchemaPath);
c.setNodeType(old.getNodeType());
c.setNodeParameter(old.getNodeParameter());
if (newParent instanceof ModuleBuilder) {
ModuleBuilder parent = (ModuleBuilder) newParent;
if (updateQName) {
- newQName = new QName(parent.getNamespace(), parent.getRevision(), parent.getPrefix(), old.getQName()
+ newQName = QName.create(parent.getQNameModule(), parent.getPrefix(), old.getQName()
.getLocalName());
} else {
newQName = old.getQName();
AugmentationSchemaBuilder augment = (AugmentationSchemaBuilder) newParent;
ModuleBuilder parent = BuilderUtils.getParentModule(newParent);
if (updateQName) {
- newQName = new QName(parent.getNamespace(), parent.getRevision(), parent.getPrefix(), old.getQName()
+ newQName = QName.create(parent.getQNameModule(), parent.getPrefix(), old.getQName()
.getLocalName());
} else {
newQName = old.getQName();
}
- newSchemaPath = augment.getTargetNodeSchemaPath().createChild(newQName);
+ newSchemaPath = augment.getTargetPath().createChild(newQName);
} else if (newParent instanceof SchemaNodeBuilder) {
SchemaNodeBuilder parent = (SchemaNodeBuilder) newParent;
QName parentQName = parent.getQName();
if (updateQName) {
- newQName = new QName(parentQName.getNamespace(), parentQName.getRevision(), parentQName.getPrefix(),
- old.getQName().getLocalName());
+ newQName = QName.create(parentQName, old.getQName().getLocalName());
} else {
newQName = old.getQName();
}