- def DataSchemaNode findInstanceDataChild(DataNodeContainer container, String name, URI moduleNamespace) {
- var DataSchemaNode potentialNode = null
- if (moduleNamespace === null) {
- potentialNode = container.getDataChildByName(name);
- } else {
- potentialNode = container.childNodes.filter[n|n.QName.localName == name && n.QName.namespace == moduleNamespace].head
- }
-
- if (potentialNode.instantiatedDataSchema) {
- return potentialNode;
+ def DataSchemaNode findInstanceDataChildByNameAndNamespace(DataNodeContainer container,
+ String name, URI namespace) {
+ Preconditions.checkNotNull(namespace)
+ val potentialSchemaNodes = container.findInstanceDataChildrenByName(name)
+ return potentialSchemaNodes.filter[n|n.QName.namespace == namespace].head
+ }
+
+ def List<DataSchemaNode> findInstanceDataChildrenByName(DataNodeContainer container, String name) {
+ Preconditions.checkNotNull(container)
+ Preconditions.checkNotNull(name)
+ val instantiatedDataNodeContainers = new ArrayList
+ instantiatedDataNodeContainers.collectInstanceDataNodeContainers(container, name)
+ return instantiatedDataNodeContainers
+ }
+
+ private def void collectInstanceDataNodeContainers(List<DataSchemaNode> potentialSchemaNodes, DataNodeContainer container,
+ String name) {
+ val nodes = container.childNodes.filter[n|n.QName.localName == name]
+ for (potentialNode : nodes) {
+ if (potentialNode.isInstantiatedDataSchema) {
+ potentialSchemaNodes.add(potentialNode)
+ }