import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
import org.opendaylight.yangtools.binding.generator.util.BindingTypes;
import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
notification.getChildNodes());
listenerInterface.addMethod("on" + notificationInterface.getName())
- .setAccessModifier(AccessModifier.PUBLIC).addParameter(notificationInterface, "notification")
- .setComment(notification.getDescription()).setReturnType(Types.VOID);
+ .setAccessModifier(AccessModifier.PUBLIC).addParameter(notificationInterface, "notification")
+ .setComment(notification.getDescription()).setReturnType(Types.VOID);
}
}
.getQNameModule());
final String returnTypeName = BindingMapping.getClassName(baseIdentity.getQName());
final GeneratedTransferObject gto = new GeneratedTOBuilderImpl(returnTypePkgName, returnTypeName)
- .toInstance();
+ .toInstance();
newType.setExtendsType(gto);
}
newType.setAbstract(true);
private void groupingsToGenTypes(final Module module, final Collection<GroupingDefinition> groupings) {
final String basePackageName = BindingMapping.getRootPackageName(module.getQNameModule());
final List<GroupingDefinition> groupingsSortedByDependencies = new GroupingDefinitionDependencySort()
- .sort(groupings);
+ .sort(groupings);
for (GroupingDefinition grouping : groupingsSortedByDependencies) {
groupingToGenType(basePackageName, grouping, module);
}
* added to it.
*/
private GeneratedTypeBuilder resolveDataSchemaNodes(final Module module, final String basePackageName,
- final GeneratedTypeBuilder parent, final GeneratedTypeBuilder childOf, final Set<DataSchemaNode> schemaNodes) {
- if ((schemaNodes != null) && (parent != null)) {
+ final GeneratedTypeBuilder parent, final GeneratedTypeBuilder childOf, final Iterable<DataSchemaNode> schemaNodes) {
+ if (schemaNodes != null && parent != null) {
for (DataSchemaNode schemaNode : schemaNodes) {
if (!schemaNode.isAugmenting() && !schemaNode.isAddedByUses()) {
addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, parent, childOf, module);
*/
private GeneratedTypeBuilder augSchemaNodeToMethods(final Module module, final String basePackageName,
final GeneratedTypeBuilder typeBuilder, final GeneratedTypeBuilder childOf,
- final Set<DataSchemaNode> schemaNodes) {
+ final Iterable<DataSchemaNode> schemaNodes) {
if ((schemaNodes != null) && (typeBuilder != null)) {
for (DataSchemaNode schemaNode : schemaNodes) {
if (!schemaNode.isAugmenting()) {
caseTypeBuilder.addImplementsType(refChoiceType);
genCtx.get(module).addCaseType(caseNode.getPath(), caseTypeBuilder);
genCtx.get(module).addChoiceToCaseMapping(refChoiceType, caseTypeBuilder, caseNode);
- final Set<DataSchemaNode> caseChildNodes = caseNode.getChildNodes();
+ final Iterable<DataSchemaNode> caseChildNodes = caseNode.getChildNodes();
if (caseChildNodes != null) {
Object parentNode = null;
final SchemaPath nodeSp = choiceNode.getPath();
if (targetSchemaNode == null) {
throw new IllegalStateException(
"Failed to find target node from grouping for augmentation " + augSchema
- + " in module " + module.getName());
+ + " in module " + module.getName());
}
}
parent = targetSchemaNode;
* </ul>
*/
private void generateTypesFromAugmentedChoiceCases(final Module module, final String basePackageName,
- final Type targetType, final ChoiceNode targetNode, final Set<DataSchemaNode> augmentedNodes) {
+ final Type targetType, final ChoiceNode targetNode, final Iterable<DataSchemaNode> augmentedNodes) {
checkArgument(basePackageName != null, "Base Package Name cannot be NULL.");
checkArgument(targetType != null, "Referenced Choice Type cannot be NULL.");
checkArgument(augmentedNodes != null, "Set of Choice Case Nodes cannot be NULL.");
} else {
node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
}
- final Set<DataSchemaNode> childNodes = node.getChildNodes();
+ final Iterable<DataSchemaNode> childNodes = node.getChildNodes();
if (childNodes != null) {
resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, childNodes);
}
}
private DataSchemaNode searchInChoices(final DataNodeContainer node, final QName arg) {
- Set<DataSchemaNode> children = node.getChildNodes();
- for (DataSchemaNode child : children) {
+ for (DataSchemaNode child : node.getChildNodes()) {
if (child instanceof ChoiceNode) {
ChoiceNode choiceNode = (ChoiceNode) child;
DataSchemaNode potential = searchInCases(choiceNode, arg);
for (Map.Entry<Type, AugmentationSchema> entry : bimap.entrySet()) {
Type key = entry.getKey();
AugmentationSchema value = entry.getValue();
- Set<DataSchemaNode> augmentedNodes = value.getChildNodes();
- if (augmentedNodes != null && !(augmentedNodes.isEmpty())) {
+ Collection<DataSchemaNode> augmentedNodes = value.getChildNodes();
+ if (augmentedNodes != null && !augmentedNodes.isEmpty()) {
typeToAugment.put(key, value);
}
}
*/
package org.opendaylight.yangtools.sal.binding.yang.types;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import org.opendaylight.yangtools.yang.parser.util.TopologicalSort;
import org.opendaylight.yangtools.yang.parser.util.TopologicalSort.Node;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
public class GroupingDefinitionDependencySort {
/**
* data node container which can contain some uses of grouping
* @return set of uses nodes which were find in <code>container</code>.
*/
- private Set<UsesNode> getAllUsesNodes(DataNodeContainer container) {
+ private Set<UsesNode> getAllUsesNodes(final DataNodeContainer container) {
Set<UsesNode> ret = new HashSet<>();
Set<UsesNode> usesNodes = container.getUses();
ret.addAll(usesNodes);
for (GroupingDefinition groupingDefinition : groupings) {
ret.addAll(getAllUsesNodes(groupingDefinition));
}
- Set<DataSchemaNode> childNodes = container.getChildNodes();
- for (DataSchemaNode childNode : childNodes) {
+ for (DataSchemaNode childNode : container.getChildNodes()) {
if (childNode instanceof DataNodeContainer) {
ret.addAll(getAllUsesNodes((DataNodeContainer) childNode));
} else if (childNode instanceof ChoiceNode) {
return targetPathNodes
}
- private def DataSchemaNode findNodeInChildNodes(QName findingNode, Set<DataSchemaNode> childNodes) {
+ private def DataSchemaNode findNodeInChildNodes(QName findingNode, Iterable<DataSchemaNode> childNodes) {
for(child : childNodes) {
if (child.QName.equals(findingNode))
return child;
'''
}
- def CharSequence printChildren(Set<DataSchemaNode> nodes, int level, InstanceIdentifier path) {
+ def CharSequence printChildren(Iterable<DataSchemaNode> nodes, int level, InstanceIdentifier path) {
val anyxmlNodes = nodes.filter(AnyXmlSchemaNode)
val leafNodes = nodes.filter(LeafSchemaNode)
val leafListNodes = nodes.filter(LeafListSchemaNode)
'''
}
- def CharSequence xmlExample(Set<DataSchemaNode> nodes, QName name,InstanceIdentifier path) '''
+ def CharSequence xmlExample(Iterable<DataSchemaNode> nodes, QName name,InstanceIdentifier path) '''
<pre>
«xmlExampleTag(name,nodes.xmplExampleTags(path))»
</pre>
'''
- def CharSequence xmplExampleTags(Set<DataSchemaNode> nodes, InstanceIdentifier identifier) '''
+ def CharSequence xmplExampleTags(Iterable<DataSchemaNode> nodes, InstanceIdentifier identifier) '''
<!-- Child nodes -->
«FOR node : nodes»
<!-- «node.QName.localName» -->
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+import com.google.common.collect.ImmutableSet;
+
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.ImmutableSet;
-
public class MultipleRevisionsSupportTest {
public static final YangModuleInfo TOPOLOGY_OLD_MODULE = org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev130712.$YangModuleInfoImpl
verifyBindingDifference(schemaContext, TOPOLOGY_OLD_MODULE, TOPOLOGY_NEW_MODULE);
}
- private SchemaContext contextVerified(List<InputStream> streams) {
+ private SchemaContext contextVerified(final List<InputStream> streams) {
YangParserImpl parser = new YangParserImpl();
Set<Module> modules = parser.parseYangModelsFromStreams(streams);
assertNotNull(modules);
return context;
}
- private void verifyBindingDifference(SchemaContext schemaContext, YangModuleInfo oldModule, YangModuleInfo newModule) {
+ private void verifyBindingDifference(final SchemaContext schemaContext, final YangModuleInfo oldModule, final YangModuleInfo newModule) {
generatedTypesVerified(schemaContext, oldModule, newModule);
}
- private Map<Module, ModuleContext> generatedTypesVerified(SchemaContext schemaContext, YangModuleInfo oldModule,
- YangModuleInfo newModule) {
+ private Map<Module, ModuleContext> generatedTypesVerified(final SchemaContext schemaContext, final YangModuleInfo oldModule,
+ final YangModuleInfo newModule) {
BindingGeneratorImpl generator = new BindingGeneratorImpl();
generator.generateTypes(schemaContext);
return generator.getModuleContexts();
}
- private void verifySchemaDifference(SchemaContext context, YangModuleInfo topologyOldModule,
- YangModuleInfo topologyNewModule) {
+ private void verifySchemaDifference(final SchemaContext context, final YangModuleInfo topologyOldModule,
+ final YangModuleInfo topologyNewModule) {
Module oldModel = context.findModuleByNamespaceAndRevision(//
URI.create(TOPOLOGY_OLD_MODULE.getNamespace()), QName.parseRevision(TOPOLOGY_OLD_MODULE.getRevision()));
assertDeepRevision(TOPOLOGY_NEW_MODULE.getRevision(), newNode);
}
- private static void assertDeepRevision(String revision, SchemaNode node) {
+ private static void assertDeepRevision(final String revision, final SchemaNode node) {
assertEquals("Wrong revision: " + node.getPath(), revision, node.getQName().getFormattedRevision());
if (node instanceof DataNodeContainer) {
for (DataSchemaNode child : ((DataNodeContainer) node).getChildNodes()) {
}
}
- private static final SchemaNode findSchemaNode(DataNodeContainer container, String... pathArgs) {
+ private static final SchemaNode findSchemaNode(final DataNodeContainer container, final String... pathArgs) {
DataNodeContainer previous = container;
SchemaNode result = (container instanceof SchemaNode) ? (SchemaNode) container : null;
if (previous == null) {
return null;
}
- Set<DataSchemaNode> childs = previous.getChildNodes();
- for (DataSchemaNode child : childs) {
+ for (DataSchemaNode child : previous.getChildNodes()) {
if (child.getQName().getLocalName().equals(arg)) {
if (child instanceof DataNodeContainer) {
previous = (DataNodeContainer) child;
return result;
}
- private static final Iterable<? extends InputStream> toInputStreams(Set<YangModuleInfo> moduleInfos)
+ private static final Iterable<? extends InputStream> toInputStreams(final Set<YangModuleInfo> moduleInfos)
throws Exception {
Builder<InputStream> streams = ImmutableList.<InputStream> builder();
for (YangModuleInfo yangModuleInfo : moduleInfos) {
import static com.google.common.base.Preconditions.checkState;
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-
public class XmlDocumentUtils {
private static class ElementWithSchemaContext {
Element element;
checkState(qName.getLocalName().equals(xmlElement.getLocalName()));
}
- public static final Optional<DataSchemaNode> findFirstSchema(final QName qname, final Set<DataSchemaNode> dataSchemaNode) {
- if (dataSchemaNode != null && !dataSchemaNode.isEmpty() && qname != null) {
+ public static final Optional<DataSchemaNode> findFirstSchema(final QName qname, final Iterable<DataSchemaNode> dataSchemaNode) {
+ if (dataSchemaNode != null && qname != null) {
for (DataSchemaNode dsn : dataSchemaNode) {
if (qname.isEqualWithoutRevision(dsn.getQName())) {
return Optional.<DataSchemaNode> of(dsn);
return ImmutableCompositeNode.create(qname, values.build());
}
- public static List<Node<?>> toDomNodes(final Element element, final Optional<Set<DataSchemaNode>> context,final SchemaContext schemaCtx) {
+ public static List<Node<?>> toDomNodes(final Element element, final Optional<? extends Iterable<DataSchemaNode>> context, final SchemaContext schemaCtx) {
return forEachChild(element.getChildNodes(),schemaCtx, new Function<ElementWithSchemaContext, Optional<Node<?>>>() {
@Override
QName partialQName = qNameFromElement(input.getElement());
Optional<DataSchemaNode> schemaNode = findFirstSchema(partialQName, context.get());
if (schemaNode.isPresent()) {
- return Optional.<Node<?>> fromNullable(//
+ return Optional.<Node<?>> fromNullable(
toNodeWithSchema(input.getElement(), schemaNode.get(), XmlUtils.DEFAULT_XML_CODEC_PROVIDER, input.getSchemaContext()));
}
}
}
- public static List<Node<?>> toDomNodes(final Element element, final Optional<Set<DataSchemaNode>> context) {
- return toDomNodes(element,context,null);
+ public static List<Node<?>> toDomNodes(final Element element, final Optional<? extends Iterable<DataSchemaNode>> context) {
+ return toDomNodes(element, context, null);
}
/**
final Optional<NotificationDefinition> notificationDef = findNotification(partialQName,
notifications.get());
if (notificationDef.isPresent()) {
- final Set<DataSchemaNode> dataNodes = notificationDef.get().getChildNodes();
+ final Iterable<DataSchemaNode> dataNodes = notificationDef.get().getChildNodes();
final List<Node<?>> domNodes = toDomNodes(childElement,
- Optional.<Set<DataSchemaNode>> fromNullable(dataNodes),schemaCtx);
+ Optional.<Iterable<DataSchemaNode>> fromNullable(dataNodes),schemaCtx);
return ImmutableCompositeNode.create(notificationDef.get().getQName(), domNodes);
}
}
private SchemaUtils() {
}
- public static final Optional<DataSchemaNode> findFirstSchema(final QName qname, final Set<DataSchemaNode> dataSchemaNode) {
- if (dataSchemaNode != null && !dataSchemaNode.isEmpty() && qname != null) {
+ public static final Optional<DataSchemaNode> findFirstSchema(final QName qname, final Iterable<DataSchemaNode> dataSchemaNode) {
+ if (dataSchemaNode != null && qname != null) {
for (DataSchemaNode dsn : dataSchemaNode) {
if (qname.isEqualWithoutRevision(dsn.getQName())) {
return Optional.<DataSchemaNode> of(dsn);
}
public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname) {
- Set<DataSchemaNode> childNodes = schema.getChildNodes();
- return findSchemaForChild(schema, qname, childNodes);
+ return findSchemaForChild(schema, qname, schema.getChildNodes());
}
- public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final Set<DataSchemaNode> childNodes) {
+ public static DataSchemaNode findSchemaForChild(final DataNodeContainer schema, final QName qname, final Iterable<DataSchemaNode> childNodes) {
Optional<DataSchemaNode> childSchema = findFirstSchema(qname, childNodes);
Preconditions.checkState(childSchema.isPresent(),
"Unknown child(ren) node(s) detected, identified by: %s, in: %s", qname, schema);
* @return Map with all child nodes, to their most top augmentation
*/
public static Map<QName, ChoiceNode> mapChildElementsFromChoices(final DataNodeContainer schema) {
- Set<DataSchemaNode> childNodes = schema.getChildNodes();
-
- return mapChildElementsFromChoices(schema, childNodes);
+ return mapChildElementsFromChoices(schema, schema.getChildNodes());
}
- private static Map<QName, ChoiceNode> mapChildElementsFromChoices(final DataNodeContainer schema, final Set<DataSchemaNode> childNodes) {
+ private static Map<QName, ChoiceNode> mapChildElementsFromChoices(final DataNodeContainer schema, final Iterable<DataSchemaNode> childNodes) {
Map<QName, ChoiceNode> mappedChoices = Maps.newLinkedHashMap();
for (final DataSchemaNode childSchema : childNodes) {
*/
package org.opendaylight.yangtools.yang.data.impl.schema;
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
import java.io.InputStream;
import java.net.URI;
import java.util.Collections;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
public class NormalizedDataBuilderTest {
private ContainerSchemaNode containerNode;
private SchemaContext schema;
- SchemaContext parseTestSchema(String... yangPath) {
+ SchemaContext parseTestSchema(final String... yangPath) {
YangParserImpl yangParserImpl = new YangParserImpl();
Set<Module> modules = yangParserImpl.parseYangModelsFromStreams(getTestYangs(yangPath));
return yangParserImpl.resolveSchemaContext(modules);
}
- List<InputStream> getTestYangs(String... yangPaths) {
+ List<InputStream> getTestYangs(final String... yangPaths) {
return Lists.newArrayList(Collections2.transform(Lists.newArrayList(yangPaths),
new Function<String, InputStream>() {
- @Override
- public InputStream apply(String input) {
- InputStream resourceAsStream = getClass().getResourceAsStream(input);
- Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
- return resourceAsStream;
- }
- }));
+ @Override
+ public InputStream apply(final String input) {
+ InputStream resourceAsStream = getClass().getResourceAsStream(input);
+ Preconditions.checkNotNull(resourceAsStream, "File %s was null", resourceAsStream);
+ return resourceAsStream;
+ }
+ }));
}
@Before
.withChildValue(1)
.withChild(
Builders.<Integer> leafSetEntryBuilder()
- .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3)).withValue(3).build())
- .build();
+ .withNodeIdentifier(getNodeWithValueIdentifier("leaf", 3)).withValue(3).build())
+ .build();
builder.withChild(leafList);
// list
.mapEntryBuilder()
.withChild(
Builders.<Integer> leafBuilder().withNodeIdentifier(getNodeIdentifier("uint32InList"))
- .withValue(1).build())
- .withChild(Builders.containerBuilder().withNodeIdentifier(getNodeIdentifier("containerInList")).build())
- .withNodeIdentifier(
- new InstanceIdentifier.NodeIdentifierWithPredicates(getNodeIdentifier("list").getNodeType(),
- Collections.singletonMap(getNodeIdentifier("uint32InList").getNodeType(), (Object) 1)))
- .build();
+ .withValue(1).build())
+ .withChild(Builders.containerBuilder().withNodeIdentifier(getNodeIdentifier("containerInList")).build())
+ .withNodeIdentifier(
+ new InstanceIdentifier.NodeIdentifierWithPredicates(getNodeIdentifier("list").getNodeType(),
+ Collections.singletonMap(getNodeIdentifier("uint32InList").getNodeType(), (Object) 1)))
+ .build();
MapNode list = Builders.mapBuilder().withChild(listChild1).withNodeIdentifier(getNodeIdentifier("list"))
.build();
.augmentationBuilder()
.withNodeIdentifier(
new InstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(getQName("augmentUint32"))))
- .withChild(
- Builders.<Integer> leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32"))
+ .withChild(
+ Builders.<Integer> leafBuilder().withNodeIdentifier(getNodeIdentifier("augmentUint32"))
.withValue(11).build()).build();
builder.withChild(augmentation);
// .build());
}
- private AugmentationSchema getAugmentationSchemaForChild(ContainerSchemaNode containerNode, QName qName) {
+ private AugmentationSchema getAugmentationSchemaForChild(final ContainerSchemaNode containerNode, final QName qName) {
for (AugmentationSchema augmentationSchema : containerNode.getAvailableAugmentations()) {
if (augmentationSchema.getDataChildByName(qName) != null) {
return augmentationSchema;
throw new IllegalStateException("Unable to find child augmentation in " + containerNode);
}
- private InstanceIdentifier.NodeWithValue getNodeWithValueIdentifier(String localName, Object value) {
+ private InstanceIdentifier.NodeWithValue getNodeWithValueIdentifier(final String localName, final Object value) {
return new InstanceIdentifier.NodeWithValue(getQName(localName), value);
}
- private QName getQName(String localName) {
+ private QName getQName(final String localName) {
String namespace = "namespace";
return new QName(URI.create(namespace), localName);
}
- private InstanceIdentifier.NodeIdentifier getNodeIdentifier(String localName) {
+ private InstanceIdentifier.NodeIdentifier getNodeIdentifier(final String localName) {
return new InstanceIdentifier.NodeIdentifier(getQName(localName));
}
- public static DataSchemaNode getSchemaNode(SchemaContext context, String moduleName, String childNodeName) {
+ public static DataSchemaNode getSchemaNode(final SchemaContext context, final String moduleName, final String childNodeName) {
for (Module module : context.getModules()) {
if (module.getName().equals(moduleName)) {
DataSchemaNode found = findChildNode(module.getChildNodes(), childNodeName);
throw new IllegalStateException("Unable to find child node " + childNodeName);
}
- static DataSchemaNode findChildNode(Set<DataSchemaNode> children, String name) {
+ private static DataSchemaNode findChildNode(final Iterable<DataSchemaNode> children, final String name) {
List<DataNodeContainer> containers = Lists.newArrayList();
for (DataSchemaNode dataSchemaNode : children) {
- if (dataSchemaNode.getQName().getLocalName().equals(name))
+ if (dataSchemaNode.getQName().getLocalName().equals(name)) {
return dataSchemaNode;
+ }
if (dataSchemaNode instanceof DataNodeContainer) {
containers.add((DataNodeContainer) dataSchemaNode);
} else if (dataSchemaNode instanceof ChoiceNode) {
*/
package org.opendaylight.yangtools.yang.model.api;
+import java.util.Collection;
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
/**
* Returns set of all child nodes defined within this DataNodeContainer.
+ * Although the return type is a collection, each node is guaranteed to
+ * be present at most once.
*
* @return child nodes in lexicographical order
*/
- Set<DataSchemaNode> getChildNodes();
+ Collection<DataSchemaNode> getChildNodes();
/**
* Returns set of all groupings defined within this DataNodeContainer.
package org.opendaylight.yangtools.yang.model.util;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
return;
}
- final Set<DataSchemaNode> childNodes = dataNode.getChildNodes();
+ final Iterable<DataSchemaNode> childNodes = dataNode.getChildNodes();
if (childNodes != null) {
for (DataSchemaNode childNode : childNodes) {
if (childNode.isAugmenting()) {
@Override
public boolean hasNext() {
if (container.getChildNodes() != null) {
- final Set<DataSchemaNode> childNodes = container.getChildNodes();
+ final Collection<DataSchemaNode> childNodes = container.getChildNodes();
if ((childNodes != null) && !childNodes.isEmpty()) {
return childNodes.iterator().hasNext();
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
+
import org.apache.commons.io.IOUtils;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
}
public static Set<DataSchemaNodeBuilder> wrapChildNodes(final String moduleName, final int line,
- final Set<DataSchemaNode> nodes, final SchemaPath parentPath, final QName parentQName) {
- Set<DataSchemaNodeBuilder> result = new LinkedHashSet<>();
+ final Collection<DataSchemaNode> nodes, final SchemaPath parentPath, final QName parentQName) {
+ Set<DataSchemaNodeBuilder> result = new LinkedHashSet<>(nodes.size());
for (DataSchemaNode node : nodes) {
QName qname = QName.create(parentQName, node.getQName().getLocalName());
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Set;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
expectedSchemaPath = SchemaPath.create(qnames, true);
assertEquals(expectedSchemaPath, augment.getTargetPath());
- Set<DataSchemaNode> augmentChildren = augment.getChildNodes();
+ Collection<DataSchemaNode> augmentChildren = augment.getChildNodes();
assertEquals(4, augmentChildren.size());
for (DataSchemaNode dsn : augmentChildren) {
TestUtils.checkIsAugmenting(dsn, false);
qnames.add(qname);
expectedPath = SchemaPath.create(qnames, true);
assertEquals(expectedPath, id.getPath());
- Set<DataSchemaNode> idChildren = id.getChildNodes();
+ Collection<DataSchemaNode> idChildren = id.getChildNodes();
assertEquals(1, idChildren.size());
// case node1
qnames.set(4, qname);
expectedPath = SchemaPath.create(qnames, true);
assertEquals(expectedPath, node1.getPath());
- Set<DataSchemaNode> node1Children = node1.getChildNodes();
+ Collection<DataSchemaNode> node1Children = node1.getChildNodes();
assertTrue(node1Children.isEmpty());
// case node2
qnames.set(4, qname);
expectedPath = SchemaPath.create(qnames, true);
assertEquals(expectedPath, node2.getPath());
- Set<DataSchemaNode> node2Children = node2.getChildNodes();
+ Collection<DataSchemaNode> node2Children = node2.getChildNodes();
assertTrue(node2Children.isEmpty());
// case node3
qnames.set(4, qname);
expectedPath = SchemaPath.create(qnames, true);
assertEquals(expectedPath, node3.getPath());
- Set<DataSchemaNode> node3Children = node3.getChildNodes();
+ Collection<DataSchemaNode> node3Children = node3.getChildNodes();
assertEquals(1, node3Children.size());
// test cases
assertEquals(qnames[3], attach.getQName());
expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
assertEquals(expectedPath, attach.getPath());
- Set<DataSchemaNode> attachChildren = attach.getChildNodes();
+ Collection<DataSchemaNode> attachChildren = attach.getChildNodes();
assertEquals(1, attachChildren.size());
// case create
assertEquals(qnames[3], create.getQName());
expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
assertEquals(expectedPath, create.getPath());
- Set<DataSchemaNode> createChildren = create.getChildNodes();
+ Collection<DataSchemaNode> createChildren = create.getChildNodes();
assertEquals(1, createChildren.size());
// case attach
assertEquals(qnames[3], destroy.getQName());
expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
assertEquals(expectedPath, destroy.getPath());
- Set<DataSchemaNode> destroyChildren = destroy.getChildNodes();
+ Collection<DataSchemaNode> destroyChildren = destroy.getChildNodes();
assertEquals(1, destroyChildren.size());
}
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
Set<GroupingDefinition> groupings = testModule.getGroupings();
assertEquals(1, groupings.size());
GroupingDefinition grouping = groupings.iterator().next();
- Set<DataSchemaNode> children = grouping.getChildNodes();
+ Collection<DataSchemaNode> children = grouping.getChildNodes();
assertEquals(5, children.size());
}
assertEquals(1, usesAugments.size());
AugmentationSchema augment = usesAugments.iterator().next();
assertEquals("inner augment", augment.getDescription());
- Set<DataSchemaNode> children = augment.getChildNodes();
+ Collection<DataSchemaNode> children = augment.getChildNodes();
assertEquals(1, children.size());
DataSchemaNode leaf = children.iterator().next();
assertTrue(leaf instanceof LeafSchemaNode);
SchemaPath expectedPath;
// grouping-U
- Set<DataSchemaNode> childNodes = gu.getChildNodes();
+ Collection<DataSchemaNode> childNodes = gu.getChildNodes();
assertEquals(7, childNodes.size());
LeafSchemaNode leafGroupingU = (LeafSchemaNode) gu.getDataChildByName("leaf-grouping-U");
import java.io.IOException;
import java.net.URISyntaxException;
+import java.util.Collection;
import java.util.Set;
+
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
Set<Module> modules = TestUtils.loadModules(getClass().getResource("/model").toURI());
Module foo = TestUtils.findModule(modules, "foo");
- Set<DataSchemaNode> childNodes = foo.getChildNodes();
+ Collection<DataSchemaNode> childNodes = foo.getChildNodes();
String[] expectedOrder = new String[] { "int32-leaf", "string-leaf", "length-leaf", "decimal-leaf",
"decimal-leaf2", "ext", "union-leaf", "custom-union-leaf", "transfer", "datas", "mycont", "data",
"how", "address", "port", "addresses", "peer" };
assertEquals(1, groupings.size());
GroupingDefinition target = groupings.iterator().next();
- Set<DataSchemaNode> childNodes = target.getChildNodes();
+ Collection<DataSchemaNode> childNodes = target.getChildNodes();
String[] expectedOrder = new String[] { "data", "how", "address", "port", "addresses" };
String[] actualOrder = new String[childNodes.size()];
public void testOrderingNestedChildNodes3() throws Exception {
Module baz = TestUtils.loadModule(getClass().getResourceAsStream("/ordering/foo.yang"));
ContainerSchemaNode x = (ContainerSchemaNode) baz.getDataChildByName("x");
- Set<DataSchemaNode> childNodes = x.getChildNodes();
+ Collection<DataSchemaNode> childNodes = x.getChildNodes();
- String[] expectedOrder = new String[] { "x15", "x10", "x5", "x1", "a5", "a1", "x2", "b5", "b1", "x3", "ax15",
- "ax5" };
+ String[] expectedOrder = new String[] { "x15", "x10", "x5", "x1", "a5", "a1", "x2", "b5", "b1", "x3", "ax15", "ax5" };
String[] actualOrder = new String[childNodes.size()];
int i = 0;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.Lists;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
path.offer(expectedQName);
SchemaPath expectedPath = SchemaPath.create(path, true);
assertEquals(expectedPath, pcreq.getPath());
- Set<DataSchemaNode> childNodes = pcreq.getChildNodes();
+ Collection<DataSchemaNode> childNodes = pcreq.getChildNodes();
assertEquals(4, childNodes.size());
// * |-- leaf version
LeafSchemaNode version = (LeafSchemaNode) pcreq.getDataChildByName("version");