checkState(augSchema.targetPath !== null,
"Augmentation Schema does not contain Target Path (Target Path is NULL).");
- processUsesAugments(augSchema, module);
-\r
+ processUsesAugments(augSchema, module);\r
val targetPath = augSchema.targetPath;
var targetSchemaNode = findDataSchemaNode(schemaContext, targetPath);\r
if (targetSchemaNode instanceof DataSchemaNode && (targetSchemaNode as DataSchemaNode).isAddedByUses()) {
}\r
\r
if (targetSchemaNode == null) {\r
- throw new IllegalArgumentException("augment target not found")\r
+ throw new IllegalArgumentException("augment target not found: " + targetPath)\r
}\r
if (targetSchemaNode !== null) {
return null
}
- var String currentName = node.QName.localName\r
+ var QName currentName = node.QName\r
var Object currentNode = node
var Object parent = node;\r
- val tmpPath = new ArrayList<String>()\r
+ val tmpPath = new ArrayList<QName>()\r
val tmpTree = new ArrayList<SchemaNode>()\r
var AugmentationSchema augment = null;
tmpTree.add(currentNode as SchemaNode)\r
augment = findNodeInAugment((parent as AugmentationTarget).availableAugmentations, currentName);
if (augment == null) {
- currentName = (parent as DataSchemaNode).QName.localName;\r
+ currentName = (parent as DataSchemaNode).QName\r
currentNode = parent
}
}
var DataSchemaNode result = null;
for (name : tmpPath) {
if (actualParent instanceof DataNodeContainer) {
- result = (actualParent as DataNodeContainer).getDataChildByName(name);
- actualParent = (actualParent as DataNodeContainer).getDataChildByName(name);
+ result = (actualParent as DataNodeContainer).getDataChildByName(name.localName);
+ actualParent = (actualParent as DataNodeContainer).getDataChildByName(name.localName);
} else {
if (actualParent instanceof ChoiceNode) {
- result = (actualParent as ChoiceNode).getCaseNodeByName(name);
- actualParent = (actualParent as ChoiceNode).getCaseNodeByName(name);
+ result = (actualParent as ChoiceNode).getCaseNodeByName(name.localName);
+ actualParent = (actualParent as ChoiceNode).getCaseNodeByName(name.localName);
}
}
}
}
}
- private def AugmentationSchema findNodeInAugment(Collection<AugmentationSchema> augments, String name) {
- for (augment : augments) {
- if (augment.getDataChildByName(name) != null) {
+ private def AugmentationSchema findNodeInAugment(Collection<AugmentationSchema> augments, QName name) {
+ for (augment : augments) {\r
+ val DataSchemaNode node = augment.getDataChildByName(name);\r
+ if (node != null) {
return augment;
}
}
return result\r
} else {\r
var DataSchemaNode result = null;\r
- var String currentName = node.QName.localName\r
- var tmpPath = new ArrayList<String>()\r
+ var QName currentName = node.QName\r
+ var tmpPath = new ArrayList<QName>()\r
var Object parent = null\r
val SchemaPath sp = node.path
val dataNodeParent = parent as DataNodeContainer;\r
for (u : dataNodeParent.uses) {\r
if (result == null) {\r
- result = getResultFromUses(u, currentName)\r
+ result = getResultFromUses(u, currentName.localName)\r
}\r
}\r
if (result == null) {
- currentName = (parent as SchemaNode).QName.localName
- if (parent instanceof DataSchemaNode) {
- val SchemaPath nodeSp = (parent as DataSchemaNode).path
+ currentName = (parent as SchemaNode).QName
+ if (parent instanceof SchemaNode) {
+ val SchemaPath nodeSp = (parent as SchemaNode).path
val List<QName> nodeNames = nodeSp.path
val List<QName> nodeNewNames = new ArrayList(nodeNames)
nodeNewNames.remove(nodeNewNames.size - 1)
List<SchemaNode> dataTree) {\r
\r
var DataSchemaNode result = null;
- var String currentName = node.QName.localName
- var tmpPath = new ArrayList<String>()\r
+ var QName currentName = node.QName
+ var tmpPath = new ArrayList<QName>()\r
tmpPath.add(currentName)\r
var int i = 1;\r
var Object parent = null
parent = parentNode
} else {
parent = dataTree.get(dataTree.size - (i+1))
- tmpPath.add((parent as SchemaNode).QName.localName);
+ tmpPath.add((parent as SchemaNode).QName)
}\r
val dataNodeParent = parent as DataNodeContainer;
for (u : dataNodeParent.uses) {
if (result == null) {\r
- result = getResultFromUses(u, currentName)
+ result = getResultFromUses(u, currentName.localName)
}
}
if (result == null) {
i = i + 1\r
- currentName = (parent as SchemaNode).QName.localName
+ currentName = (parent as SchemaNode).QName
}
} while (result == null);
\r
return gr.getDataChildByName(currentName)
}\r
\r
- private def getTargetNode(List<String> tmpPath, DataSchemaNode node) {
+ private def getTargetNode(List<QName> tmpPath, DataSchemaNode node) {
var DataSchemaNode result = node
if (tmpPath.size == 1) {
if (result != null && result.addedByUses) {
Collections.reverse(tmpPath);
tmpPath.remove(0);
- for (name : tmpPath) {
- newParent = (newParent as DataNodeContainer).getDataChildByName(name);
+ for (name : tmpPath) {\r
+ // searching by local name is must, because node has different namespace in its original location
+ newParent = (newParent as DataNodeContainer).getDataChildByName(name.localName);
}
if (newParent != null && newParent.addedByUses) {
newParent = findOriginal(newParent);
leaf tunnel-id {
type leafref {
- path "../../../link-id";
+ path "../../../at:link-id";
}
}
}
if (childNodeQName != null) {
schemaNode = nextNode.getDataChildByName(childNodeQName.getLocalName());
if(schemaNode === null && nextNode instanceof Module) {
- schemaNode = (nextNode as Module).getNotificationByName(childNodeQName.localName);
+ schemaNode = (nextNode as Module).getNotificationByName(childNodeQName);
}
if(schemaNode === null && nextNode instanceof Module) {
}
return schemaNode;
}
-
-
+
+
public static def SchemaNode findNodeInSchemaContext(SchemaContext context, List<QName> path) {
val current = path.get(0);
val module = context.findModuleByNamespaceAndRevision(current.namespace,current.revision);
}
private static def SchemaNode findNodeInModule(Module module, List<QName> path) {
- val current = path.get(0).localName;
+ val current = path.get(0)
var SchemaNode node = module.getDataChildByName(current);
if (node != null) return findNode(node as DataSchemaNode,path.nextLevel);
node = module.getRpcByName(current);
if (node != null) return findNodeInNotification(node as NotificationDefinition,path.nextLevel)
node = module.getGroupingByName(current);
if (node != null) return findNodeInGrouping(node as GroupingDefinition, path.nextLevel);
- return null
+ return node
}
private static def SchemaNode findNodeInGrouping(GroupingDefinition grouping, List<QName> path) {
if (path.empty) return grouping;
- val current = path.get(0).localName;
+ val current = path.get(0)
val node = grouping.getDataChildByName(current);
if (node != null) return findNode(node, path.nextLevel);
return null;
private static def SchemaNode findNodeInNotification(NotificationDefinition rpc,List<QName> path) {
if(path.empty) return rpc;
- val current = path.get(0).localName;
+ val current = path.get(0)
val node = rpc.getDataChildByName(current)
if(node != null) return findNode(node,path.nextLevel)
return null
private static dispatch def SchemaNode findNode(ChoiceNode parent,List<QName> path) {
if(path.empty) return parent;
- val current = path.get(0).localName;
+ val current = path.get(0)
val node = parent.getCaseNodeByName(current)
if (node != null) return findNodeInCase(node,path.nextLevel)
return null
private static dispatch def SchemaNode findNode(ContainerSchemaNode parent,List<QName> path) {
if(path.empty) return parent;
- val current = path.get(0).localName;
+ val current = path.get(0)
val node = parent.getDataChildByName(current)
if (node != null) return findNode(node,path.nextLevel)
return null
private static dispatch def SchemaNode findNode(ListSchemaNode parent,List<QName> path) {
if(path.empty) return parent;
- val current = path.get(0).localName;
+ val current = path.get(0)
val node = parent.getDataChildByName(current)
if (node != null) return findNode(node,path.nextLevel)
return null
public static def SchemaNode findNodeInCase(ChoiceCaseNode parent,List<QName> path) {
if(path.empty) return parent;
- val current = path.get(0).localName;
+ val current = path.get(0)
val node = parent.getDataChildByName(current)
if (node != null) return findNode(node,path.nextLevel)
return null
}
- public static def RpcDefinition getRpcByName(Module module, String name) {
- for(notification : module.rpcs) {
- if(notification.QName.localName == name) {
- return notification;
+ public static def RpcDefinition getRpcByName(Module module, QName name) {
+ for (rpc : module.rpcs) {
+ if (rpc.QName.equals(name)) {
+ return rpc;
}
}
return null;
return path.subList(1,path.size)
}
- public static def NotificationDefinition getNotificationByName(Module module, String name) {
+ public static def NotificationDefinition getNotificationByName(Module module, QName name) {
for(notification : module.notifications) {
- if(notification.QName.localName == name) {
+ if(notification.QName.equals(name)) {
return notification;
}
}
return null;
}
- public static def GroupingDefinition getGroupingByName(Module module, String name) {
+ public static def GroupingDefinition getGroupingByName(Module module, QName name) {
for (grouping : module.groupings) {
- if (grouping.QName.localName.equals(name)) {
+ if (grouping.QName.equals(name)) {
return grouping;
}
}
if (path != null) {
val int lenght = path.size() - colCount;
absolutePath.addAll(path.subList(0,lenght));
- absolutePath.addAll(
- xpaths.subList(colCount,xpaths.length).map[stringPathPartToQName(context, module,it)]
- )
+ val List<QName> sublist = xpaths.subList(colCount,xpaths.length).map[stringPathPartToQName(context, module,it)]
+ absolutePath.addAll(sublist)
}
}
}
import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
-import java.util.TreeMap;
import java.util.TreeSet;
import org.opendaylight.yangtools.yang.common.QName;
public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder implements DataNodeContainerBuilder {
protected QName qname;
- protected final Map<QName, DataSchemaNode> childNodes = new TreeMap<>(Comparators.QNAME_COMP);
+ protected final Set<DataSchemaNode> childNodes = new HashSet<>();
protected final Set<DataSchemaNodeBuilder> addedChildNodes = new HashSet<>();
protected final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
return qname;
}
- public Map<QName, DataSchemaNode> getChildNodes() {
+ public Set<DataSchemaNode> getChildNodes() {
return childNodes;
}
@Override
public void addChildNode(DataSchemaNode child) {
QName childName = child.getQName();
- for (QName qname : childNodes.keySet()) {
- if (qname.equals(childName)) {
+ for (DataSchemaNode childNode : childNodes) {
+ if (childNode.getQName().equals(childName)) {
throw new YangParseException(moduleName, line, "Can not add '" + child + "' to '" + this
+ "' in module '" + moduleName + "': node with same name already declared");
}
}
- childNodes.put(child.getQName(), child);
+ childNodes.add(child);
}
@Override
addedUsesNodes.add(usesNode);
}
+ public DataSchemaNode getChildNode(Set<DataSchemaNode> childNodes, QName name) {
+ for (DataSchemaNode node : childNodes) {
+ if (node.getQName().equals(name)) {
+ return node;
+ }
+ }
+ return null;
+ }
+
+ public DataSchemaNode getChildNode(Set<DataSchemaNode> childNodes, String name) {
+ for (DataSchemaNode node : childNodes) {
+ if (node.getQName().getLocalName().equals(name)) {
+ return node;
+ }
+ }
+ return null;
+ }
+
}
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
DataSchemaNode child = node.build();
- childNodes.put(child.getQName(), child);
+ childNodes.add(child);
}
instance.addChildNodes(childNodes);
private final class AugmentationSchemaImpl implements AugmentationSchema {
private SchemaPath targetPath;
private RevisionAwareXPath whenCondition;
- private final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<UsesNode> uses = new HashSet<>();
private String description;
private String reference;
@Override
public Set<DataSchemaNode> getChildNodes() {
- final Set<DataSchemaNode> result = new TreeSet<DataSchemaNode>(Comparators.SCHEMA_NODE_COMP);
- result.addAll(childNodes.values());
- return Collections.unmodifiableSet(result);
+ return Collections.unmodifiableSet(childNodes);
}
- private void addChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void addChildNodes(Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes.putAll(childNodes);
+ this.childNodes.addAll(childNodes);
}
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ return getChildNode(childNodes, name);
}
@Override
public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ return getChildNode(childNodes, name);
}
@Override
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.*;
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- DataSchemaNode child = node.build();
- childNodes.put(child.getQName(), child);
+ childNodes.add(node.build());
}
instance.addChildNodes(childNodes);
private boolean augmenting;
private boolean addedByUses;
private ConstraintDefinition constraints;
- private final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<AugmentationSchema> augmentations = new HashSet<>();
private final Set<UsesNode> uses = new HashSet<>();
private final List<UnknownSchemaNode> unknownNodes = new ArrayList<>();
@Override
public Set<DataSchemaNode> getChildNodes() {
- return Collections.unmodifiableSet(new HashSet<>(childNodes.values()));
+ return Collections.unmodifiableSet(childNodes);
}
- private void addChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void addChildNodes(Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes.putAll(childNodes);
+ this.childNodes.addAll(childNodes);
}
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ return getChildNode(childNodes, name);
}
@Override
public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ return getChildNode(childNodes, name);
}
@Override
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- DataSchemaNode child = node.build();
- childNodes.put(child.getQName(), child);
+ childNodes.add(node.build());
}
instance.addChildNodes(childNodes);
private boolean configuration;
private ConstraintDefinition constraints;
private final Set<AugmentationSchema> augmentations = new HashSet<>();
- private final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<TypeDefinition<?>> typeDefinitions = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<UsesNode> uses = new HashSet<>();
@Override
public Set<DataSchemaNode> getChildNodes() {
- final Set<DataSchemaNode> result = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
- result.addAll(childNodes.values());
- return Collections.unmodifiableSet(result);
+ return Collections.unmodifiableSet(childNodes);
}
- private void addChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void addChildNodes(Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes.putAll(childNodes);
+ this.childNodes.addAll(childNodes);
}
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ return getChildNode(childNodes, name);
}
@Override
public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ return getChildNode(childNodes, name);
}
@Override
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
if (!isBuilt) {
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- DataSchemaNode child = node.build();
- childNodes.put(child.getQName(), child);
+ childNodes.add(node.build());
}
instance.addChildNodes(childNodes);
private String reference;
private Status status;
private boolean addedByUses;
- private final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<TypeDefinition<?>> typeDefinitions = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<UsesNode> uses = new HashSet<>();
@Override
public Set<DataSchemaNode> getChildNodes() {
- final Set<DataSchemaNode> result = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
- result.addAll(childNodes.values());
- return Collections.unmodifiableSet(result);
+ return Collections.unmodifiableSet(childNodes);
}
- private void addChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void addChildNodes(Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes.putAll(childNodes);
+ this.childNodes.addAll(childNodes);
}
-
}
@Override
@Override
public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ return getChildNode(childNodes, name);
}
@Override
public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ return getChildNode(childNodes, name);
}
@Override
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
if (!isBuilt) {
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- DataSchemaNode child = node.build();
- childNodes.put(child.getQName(), child);
+ childNodes.add(node.build());
}
instance.addChildNodes(childNodes);
private boolean configuration;
private ConstraintDefinition constraints;
private final Set<AugmentationSchema> augmentations = new HashSet<>();
- private final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<TypeDefinition<?>> typeDefinitions = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<UsesNode> uses = new HashSet<>();
@Override
public Set<DataSchemaNode> getChildNodes() {
- final Set<DataSchemaNode> result = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
- result.addAll(childNodes.values());
- return Collections.unmodifiableSet(result);
+ return Collections.unmodifiableSet(childNodes);
}
- private void addChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void addChildNodes(Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes.putAll(childNodes);
+ this.childNodes.addAll(childNodes);
}
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ return getChildNode(childNodes, name);
}
@Override
public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ return getChildNode(childNodes, name);
}
@Override
revision = base.getRevision();
for (DataSchemaNode childNode : base.getChildNodes()) {
- childNodes.put(childNode.getQName(), childNode);
+ childNodes.add(childNode);
}
typedefs.addAll(base.getTypeDefinitions());
// CHILD NODES
for (DataSchemaNodeBuilder child : addedChildNodes) {
- DataSchemaNode childNode = child.build();
- childNodes.put(childNode.getQName(), childNode);
+ childNodes.add(child.build());
}
instance.addChildNodes(childNodes);
private final Set<AugmentationSchema> augmentations = new HashSet<>();
private final Set<RpcDefinition> rpcs = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<Deviation> deviations = new HashSet<>();
- private final Map<QName, DataSchemaNode> childNodes = new TreeMap<>(Comparators.QNAME_COMP);
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<UsesNode> uses = new HashSet<>();
private final List<ExtensionDefinition> extensionNodes = new ArrayList<>();
@Override
public Set<DataSchemaNode> getChildNodes() {
- final Set<DataSchemaNode> result = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
- result.addAll(childNodes.values());
- return Collections.unmodifiableSet(result);
+ return Collections.unmodifiableSet(childNodes);
}
- private void addChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void addChildNodes(Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes.putAll(childNodes);
+ this.childNodes.addAll(childNodes);
}
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ return getChildNode(childNodes, name);
}
@Override
public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ return getChildNode(childNodes, name);
}
@Override
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
if (!isBuilt) {
// CHILD NODES
for (DataSchemaNodeBuilder node : addedChildNodes) {
- DataSchemaNode child = node.build();
- childNodes.put(child.getQName(), child);
+ childNodes.add(node.build());
}
instance.setChildNodes(childNodes);
private String description;
private String reference;
private Status status = Status.CURRENT;
- private final Map<QName, DataSchemaNode> childNodes = new HashMap<>();
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
private final Set<GroupingDefinition> groupings = new HashSet<>();
private final Set<TypeDefinition<?>> typeDefinitions = new HashSet<>();
private final Set<UsesNode> uses = new HashSet<>();
@Override
public Set<DataSchemaNode> getChildNodes() {
- return Collections.unmodifiableSet(new HashSet<DataSchemaNode>(childNodes.values()));
+ return Collections.unmodifiableSet(childNodes);
}
- private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void setChildNodes(Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes.putAll(childNodes);
+ this.childNodes.addAll(childNodes);
}
}
@Override
public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ return getChildNode(childNodes, name);
}
@Override
public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ return getChildNode(childNodes, name);
}
@Override
module.getAugmentBuilders().addAll(submodule.getAugmentBuilders());
module.getAllAugments().addAll(submodule.getAllAugments());
module.getChildNodeBuilders().addAll(submodule.getChildNodeBuilders());
- module.getChildNodes().putAll(submodule.getChildNodes());
+ module.getChildNodes().addAll(submodule.getChildNodes());
module.getGroupings().addAll(submodule.getGroupings());
module.getGroupingBuilders().addAll(submodule.getGroupingBuilders());
module.getTypeDefinitions().addAll(submodule.getTypeDefinitions());
}
return result;
}
-
+
public static YangContext parseStreamWithoutErrorListeners(final InputStream yangStream) {
YangContext result = null;
try {
*/
package org.opendaylight.yangtools.yang.parser.util;
+import java.net.URI;
import java.util.Comparator;
+import java.util.Date;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
private static final class SchemaNodeComparator implements Comparator<SchemaNode> {
@Override
public int compare(SchemaNode o1, SchemaNode o2) {
- return o1.getQName().getLocalName().compareTo(o2.getQName().getLocalName());
+ QName q1 = o1.getQName();
+ QName q2 = o2.getQName();
+ int result = q1.getLocalName().compareTo(q2.getLocalName());
+ if (result == 0) {
+ URI ns1 = q1.getNamespace();
+ URI ns2 = q2.getNamespace();
+ if (ns1 == null && ns2 == null) {
+ Date rev1 = q1.getRevision();
+ Date rev2 = q2.getRevision();
+
+ if (rev1 == null && rev2 == null) {
+ String p1 = q1.getPrefix();
+ String p2 = q2.getPrefix();
+ if (p1 == null && p2 == null) {
+ throw new IllegalArgumentException("Failed to sort nodes: " + o1 + ", " + o2);
+ }
+ if (p1 == null || p2 == null) {
+ if (p1 == null) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ return p1.compareTo(p2);
+ }
+ if (rev1 == null || rev2 == null) {
+ if (rev1 == null) {
+ return -1;
+ } else {
+ return -2;
+ }
+ }
+ return rev1.compareTo(rev2);
+ }
+ if (ns1 == null || ns2 == null) {
+ if (ns1 == null) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ return ns1.toString().compareTo(ns2.toString());
+ } else {
+ return result;
+ }
}
}
UnknownSchemaNodeBuilder c = new UnknownSchemaNodeBuilder(newParent.getModuleName(), newParent.getLine(),
newQName, newSchemaPath);
+ c.setNodeType(old.getNodeType());
+ c.setNodeParameter(old.getNodeParameter());
c.setParent(newParent);
c.setDescription(old.getDescription());
c.setReference(old.getReference());