DataSchemaNodeBuilder builderData = new AnyXmlBuilder("module", 4, qname, createSchemaPath(qname));
assertNotNull("Refine holder data wasn't initialized.", refHolderData);
- RefineUtils.refineAnyxml((AnyXmlBuilder) builderData, refHolderData, 3);
+ RefineUtils.refineAnyxml((AnyXmlBuilder) builderData, refHolderData);
// data node
ConstraintsBuilder conDefData = builderData.getConstraints();
DataSchemaNodeBuilder builderChc2 = new ChoiceBuilder("module", 4, qname);
assertNotNull("Refine holder chc2 wasn't initialized.", refHolderChc2);
- RefineUtils.refineChoice((ChoiceBuilder) builderChc2, refHolderChc2, 3);
+ RefineUtils.refineChoice((ChoiceBuilder) builderChc2, refHolderChc2);
// chc2 node
ConstraintsBuilder conDefChc2 = builderChc2.getConstraints();
assertNotNull("Refine holder chc wasn't initialized.", refHolderChc);
assertNotNull("Data schema node builder chc wasn't initialized.", builderChc);
- RefineUtils.refineChoice((ChoiceBuilder) builderChc, refHolderChc, 2);
+ RefineUtils.refineChoice((ChoiceBuilder) builderChc, refHolderChc);
ChoiceBuilder choiceBuilder = null;
if (builderChc instanceof ChoiceBuilder) {
assertNotNull("Refine holder " + nodeName + " wasn't initialized.", refHolderLflst);
assertNotNull("Data schema node builder " + nodeName + " wasn't initialized.", builderLflst);
- RefineUtils.refineLeafList((LeafListSchemaNodeBuilder) builderLflst, refHolderLflst, 1);
+ RefineUtils.refineLeafList((LeafListSchemaNodeBuilder) builderLflst, refHolderLflst);
// lflst node
ConstraintsBuilder conDefLflst = builderLflst.getConstraints();
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
import org.opendaylight.yangtools.yang.parser.builder.api.DataNodeContainerBuilder;
}
}
- return new LinkedHashSet<Module>(buildWithContext(modules, context).values());
+ return new LinkedHashSet<>(buildWithContext(modules, context).values());
}
return Collections.emptySet();
}
Map<ModuleBuilder, InputStream> builderToStreamMap = Maps.newHashMap();
final Map<String, TreeMap<Date, ModuleBuilder>> modules = resolveModuleBuildersWithContext(
yangModelStreams, builderToStreamMap, context);
- return new LinkedHashSet<Module>(buildWithContext(modules, context).values());
+ return new LinkedHashSet<>(buildWithContext(modules, context).values());
}
return Collections.emptySet();
}
final Map<InputStream, ModuleBuilder> builders = new LinkedHashMap<>();
// validate yang
- new YangModelBasicValidator(walker).validate(new ArrayList<ParseTree>(trees.values()));
+ new YangModelBasicValidator(walker).validate(new ArrayList<>(trees.values()));
YangParserListenerImpl yangModelParser;
for(Map.Entry<InputStream, ParseTree> entry : trees.entrySet()) {
final SchemaContext context) {
Map<InputStream, ModuleBuilder> parsedBuilders = parseModuleBuilders(yangFileStreams, streamToBuilderMap);
ModuleBuilder[] builders = new ModuleBuilder[parsedBuilders.size()];
- final ModuleBuilder[] moduleBuilders = new ArrayList<>(parsedBuilders.values()).toArray(builders);
+ parsedBuilders.values().toArray(builders);
// module dependency graph sorted
List<ModuleBuilder> sorted;
}
TreeMap<Date, ModuleBuilder> builderByRevision = result.get(builderName);
if (builderByRevision == null) {
- builderByRevision = new TreeMap<Date, ModuleBuilder>();
+ builderByRevision = new TreeMap<>();
}
builderByRevision.put(builderRevision, builder);
result.put(builderName, builderByRevision);
resolveDeviations(modules);
// build
- final Map<ModuleBuilder, Module> result = new LinkedHashMap<ModuleBuilder, Module>();
+ final Map<ModuleBuilder, Module> result = new LinkedHashMap<>();
for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
final ModuleBuilder moduleBuilder = childEntry.getValue();
resolveDeviationsWithContext(modules, context);
// build
- final Map<ModuleBuilder, Module> result = new LinkedHashMap<ModuleBuilder, Module>();
+ final Map<ModuleBuilder, Module> result = new LinkedHashMap<>();
for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
final ModuleBuilder moduleBuilder = childEntry.getValue();
if (prefix == null) {
prefix = module.getPrefix();
}
- String name = null;
ModuleBuilder dependentModuleBuilder = findModuleFromBuilders(modules, module, prefix, line);
if (dependentModuleBuilder == null) {
- Module dependentModule = findModuleFromContext(context, module, prefix, line);
- Object currentParent = dependentModule;
+ Object currentParent = findModuleFromContext(context, module, prefix, line);
for (QName q : path) {
if (currentParent == null) {
throw new YangParseException(module.getName(), line, FAIL_DEVIATION_TARGET);
}
- name = q.getLocalName();
+ String name = q.getLocalName();
if (currentParent instanceof DataNodeContainer) {
currentParent = ((DataNodeContainer) currentParent).getDataChildByName(name);
}
* true, qname of node will be corrected based on new parent.
*
* @param old
+ * builder to copy
* @param newParent
+ * new parent
* @param updateQName
- * @return copy
+ * flag to indicate if qname should be updated based on new
+ * parent location
+ * @return copy of given builder
*/
public static DataSchemaNodeBuilder copy(DataSchemaNodeBuilder old, Builder newParent, boolean updateQName) {
if (old instanceof AnyXmlBuilder) {
DataBean data = getdata(old, newParent, updateQName);
QName newQName = data.qname;
SchemaPath newSchemaPath = data.schemaPath;
- TypeDefinitionBuilder type = null;
+ TypeDefinitionBuilder type;
if (old instanceof UnionTypeBuilder) {
UnionTypeBuilder oldUnion = (UnionTypeBuilder) old;
* Create AnyXmlBuilder from given AnyXmlSchemaNode.
*
* @param anyxml
+ * base anyxml
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* Create GroupingBuilder from given GroupingDefinition.
*
* @param grouping
+ * base grouping
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* Create TypeDefinitionBuilder from given ExtendedType.
*
* @param typedef
+ * base typedef
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* Create UnknownSchemaNodeBuilder from given UnknownSchemaNode.
*
* @param unknownNode
+ * base unknown node
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* @param leaf
* leaf from which to create builder
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* Create ContainerSchemaNodeBuilder from given ContainerSchemaNode.
*
* @param container
+ * base container
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* Create ListSchemaNodeBuilder from given ListSchemaNode.
*
* @param list
+ * base list
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* Create LeafListSchemaNodeBuilder from given LeafListSchemaNode.
*
* @param leafList
+ * base leaf-list
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
* Create ChoiceBuilder from given ChoiceNode.
*
* @param choice
+ * base choice
* @param qname
+ * new qname
* @param moduleName
* current module name
* @param line
groupingName = groupingString;
}
- ModuleBuilder dependentModule = null;
+ ModuleBuilder dependentModule;
if (groupingPrefix.equals(module.getPrefix())) {
dependentModule = module;
} else {
return null;
}
- GroupingBuilder result = null;
+ GroupingBuilder result;
Set<GroupingBuilder> groupings = dependentModule.getGroupingBuilders();
result = findGroupingBuilder(groupings, groupingName);
if (result != null) {
* Add nodes defined in uses target grouping to uses parent.
*
* @param usesNode
+ * yang uses node which will be instantiated in current location
*/
public static void updateUsesParent(UsesNodeBuilder usesNode) {
DataNodeContainerBuilder parent = usesNode.getParent();
String prefix = module.getPrefix();
SchemaPath parentPath = parent.getPath();
-
-
- if(parent instanceof AugmentationSchemaBuilder) {
- parentPath = ((AugmentationSchemaBuilder)parent).getTargetNodeSchemaPath();
+ if (parent instanceof AugmentationSchemaBuilder) {
+ parentPath = ((AugmentationSchemaBuilder) parent).getTargetNodeSchemaPath();
}
// child nodes
((GroupingMember) child).setAddedByUses(true);
}
- GroupingMember gm = (GroupingMember) child;
- if (gm.isAddedByUses()) {
- if(usesNode.isAugmenting()) {
- child.setAugmenting(true);
- }
- if(usesNode.isAugmenting() && !(usesNode.getParentAugment().getParent() instanceof UsesNodeBuilder)) {
- AugmentationSchemaBuilder parentAugment = usesNode.getParentAugment();
- ModuleBuilder m = ParserUtils.getParentModule(parentAugment);
- correctNodePathForUsesNodes(child, parentPath, m);
- } else {
- child.setQName(new QName(ns, rev, prefix, child.getQName().getLocalName()));
- correctNodePathForUsesNodes(child, parentPath, module);
+ if (child instanceof GroupingMember) {
+ GroupingMember gm = (GroupingMember) child;
+ if (gm.isAddedByUses()) {
+ if (usesNode.isAugmenting()) {
+ child.setAugmenting(true);
+ }
+ if (usesNode.isAugmenting()
+ && !(usesNode.getParentAugment().getParent() instanceof UsesNodeBuilder)) {
+ AugmentationSchemaBuilder parentAugment = usesNode.getParentAugment();
+ ModuleBuilder m = ParserUtils.getParentModule(parentAugment);
+ correctNodePathForUsesNodes(child, parentPath, m);
+ } else {
+ child.setQName(new QName(ns, rev, prefix, child.getQName().getLocalName()));
+ correctNodePathForUsesNodes(child, parentPath, module);
+ }
}
+ } else {
+ throw new YangParseException(module.getName(), usesNode.getLine(),
+ "Failed to process uses node: unresolved child node");
}
parent.addChildNode(child);
* Read child nodes defined in target grouping and make a copy of them.
*
* @param usesNode
- * @return copy of child nodes defined in uses target grouping
+ * uses node for which data will be collected
*/
private static void collectTargetChildNodes(UsesNodeBuilder usesNode) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
final Set<DataSchemaNodeBuilder> collection = new HashSet<>();
- addChildNodeToCollection(usesNode, collection, target.getChildNodeBuilders());
+ addChildNodeToCollection(usesNode, collection, target.getChildNodeBuilders(), usesNode.getParent());
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
Set<DataSchemaNodeBuilder> targetUsesChildNodes = collectTargetUsesChildNodes(targetUses,
usesNode.getParent());
- addChildNodeToCollection(usesNode, collection, targetUsesChildNodes);
+ addChildNodeToCollection(usesNode, collection, targetUsesChildNodes, usesNode.getParent());
}
usesNode.getTargetChildren().addAll(collection);
}
DataNodeContainerBuilder parent) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
final Set<DataSchemaNodeBuilder> collection = new HashSet<>(usesNode.getTargetChildren());
- addChildNodeToCollection(usesNode, collection, target.getChildNodeBuilders());
+ addChildNodeToCollection(usesNode, collection, target.getChildNodeBuilders(), parent);
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
Set<DataSchemaNodeBuilder> targetUsesChildNodes = collectTargetUsesChildNodes(targetUses, parent);
- addChildNodeToCollection(usesNode, collection, targetUsesChildNodes);
+ addChildNodeToCollection(usesNode, collection, targetUsesChildNodes, parent);
}
return collection;
}
private static void addChildNodeToCollection(UsesNodeBuilder usesNode, Set<DataSchemaNodeBuilder> collection,
- Set<DataSchemaNodeBuilder> allNodes) {
+ Set<DataSchemaNodeBuilder> allNodes, Builder parent) {
for (DataSchemaNodeBuilder childNode : allNodes) {
boolean exists = false;
for (DataSchemaNodeBuilder usesChildNode : usesNode.getTargetChildren()) {
}
}
if (!exists) {
- DataSchemaNodeBuilder copy = CopyUtils.copy(childNode, usesNode.getParent(), true);
+ DataSchemaNodeBuilder copy = CopyUtils.copy(childNode, parent, true);
collection.add(copy);
}
}
* Read typedefs defined in target grouping and make a copy of them.
*
* @param usesNode
- * @return copy of typedefs defined in uses target grouping
+ * uses node for which data will be collected
*/
private static void collectTargetTypedefs(UsesNodeBuilder usesNode) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
Set<TypeDefinitionBuilder> collection = new HashSet<>();
- addTypedefToCollection(usesNode, collection, target.getTypeDefinitionBuilders());
+ addTypedefToCollection(usesNode, collection, target.getTypeDefinitionBuilders(), usesNode.getParent());
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
Set<TypeDefinitionBuilder> targetUsesTypedefs = collectTargetUsesTypedefs(targetUses, usesNode.getParent());
- addTypedefToCollection(usesNode, collection, targetUsesTypedefs);
+ addTypedefToCollection(usesNode, collection, targetUsesTypedefs, usesNode.getParent());
}
usesNode.getTargetTypedefs().addAll(collection);
}
DataNodeContainerBuilder parent) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
Set<TypeDefinitionBuilder> collection = new HashSet<>(usesNode.getTargetTypedefs());
- addTypedefToCollection(usesNode, collection, target.getTypeDefinitionBuilders());
+ addTypedefToCollection(usesNode, collection, target.getTypeDefinitionBuilders(), parent);
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
Set<TypeDefinitionBuilder> targetUsesTypedefs = collectTargetUsesTypedefs(targetUses, parent);
- addTypedefToCollection(usesNode, collection, targetUsesTypedefs);
+ addTypedefToCollection(usesNode, collection, targetUsesTypedefs, parent);
}
return collection;
}
private static void addTypedefToCollection(UsesNodeBuilder usesNode, Set<TypeDefinitionBuilder> collection,
- Set<TypeDefinitionBuilder> allTypedefs) {
+ Set<TypeDefinitionBuilder> allTypedefs, Builder parent) {
for (TypeDefinitionBuilder childNode : allTypedefs) {
boolean exists = false;
for (TypeDefinitionBuilder usesTypedef : usesNode.getTargetTypedefs()) {
}
}
if (!exists) {
- TypeDefinitionBuilder copy = CopyUtils.copy(childNode, usesNode.getParent(), true);
+ TypeDefinitionBuilder copy = CopyUtils.copy(childNode, parent, true);
collection.add(copy);
}
}
* Read groupings defined in target grouping and make a copy of them.
*
* @param usesNode
- * @return copy of groupings defined in uses target grouping
+ * uses node for which data will be collected
*/
private static void collectTargetGroupings(UsesNodeBuilder usesNode) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
Set<GroupingBuilder> collection = new HashSet<>();
- addGroupingToCollection(usesNode, collection, target.getGroupingBuilders());
+ addGroupingToCollection(usesNode, collection, target.getGroupingBuilders(), usesNode.getParent());
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
Set<GroupingBuilder> targetUsesGrouping = collectTargetGroupings(targetUses, usesNode.getParent());
- addGroupingToCollection(usesNode, collection, targetUsesGrouping);
+ addGroupingToCollection(usesNode, collection, targetUsesGrouping, usesNode.getParent());
}
usesNode.getTargetGroupings().addAll(collection);
}
private static Set<GroupingBuilder> collectTargetGroupings(UsesNodeBuilder usesNode, DataNodeContainerBuilder parent) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
Set<GroupingBuilder> collection = new HashSet<>(usesNode.getTargetGroupings());
- addGroupingToCollection(usesNode, collection, target.getGroupingBuilders());
+ addGroupingToCollection(usesNode, collection, target.getGroupingBuilders(), parent);
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
Set<GroupingBuilder> targetUsesGroupings = collectTargetGroupings(targetUses, parent);
- addGroupingToCollection(usesNode, collection, targetUsesGroupings);
+ addGroupingToCollection(usesNode, collection, targetUsesGroupings, parent);
}
return collection;
}
private static void addGroupingToCollection(UsesNodeBuilder usesNode, Set<GroupingBuilder> collection,
- Set<GroupingBuilder> allGroupings) {
+ Set<GroupingBuilder> allGroupings, Builder parent) {
for (GroupingBuilder childNode : allGroupings) {
boolean exists = false;
for (GroupingBuilder usesGrouping : usesNode.getTargetGroupings()) {
}
}
if (!exists) {
- GroupingBuilder copy = CopyUtils.copy(childNode, usesNode.getParent(), true);
+ GroupingBuilder copy = CopyUtils.copy(childNode, parent, true);
collection.add(copy);
}
}
* Read unknown nodes defined in target grouping and make a copy of them.
*
* @param usesNode
- * @return copy of unknown nodes defined in uses target grouping
+ * uses node for which data will be collected
*/
private static void collectTargetUnknownNodes(UsesNodeBuilder usesNode) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
final List<UnknownSchemaNodeBuilder> collection = new ArrayList<>();
- addUnknownNodeToCollection(usesNode, collection, target.getUnknownNodeBuilders());
+ addUnknownNodeToCollection(usesNode, collection, target.getUnknownNodeBuilders(), usesNode.getParent());
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
List<UnknownSchemaNodeBuilder> targetUsesUnknownNodes = collectTargetUnknownNodes(targetUses,
usesNode.getParent());
- addUnknownNodeToCollection(usesNode, collection, targetUsesUnknownNodes);
+ addUnknownNodeToCollection(usesNode, collection, targetUsesUnknownNodes, usesNode.getParent());
}
usesNode.getTargetUnknownNodes().addAll(collection);
}
DataNodeContainerBuilder parent) {
final GroupingBuilder target = usesNode.getGroupingBuilder();
List<UnknownSchemaNodeBuilder> collection = new ArrayList<>(usesNode.getTargetUnknownNodes());
- addUnknownNodeToCollection(usesNode, collection, target.getUnknownNodeBuilders());
+ addUnknownNodeToCollection(usesNode, collection, target.getUnknownNodeBuilders(), parent);
for (UsesNodeBuilder targetUses : target.getUsesNodes()) {
List<UnknownSchemaNodeBuilder> targetUsesUnknownNodes = collectTargetUnknownNodes(targetUses, parent);
- addUnknownNodeToCollection(usesNode, collection, targetUsesUnknownNodes);
+ addUnknownNodeToCollection(usesNode, collection, targetUsesUnknownNodes, parent);
}
return collection;
}
private static void addUnknownNodeToCollection(UsesNodeBuilder usesNode, List<UnknownSchemaNodeBuilder> collection,
- List<UnknownSchemaNodeBuilder> allUnknownNodes) {
+ List<UnknownSchemaNodeBuilder> allUnknownNodes, Builder parent) {
for (UnknownSchemaNodeBuilder childNode : allUnknownNodes) {
boolean exists = false;
for (UnknownSchemaNodeBuilder usesUnknownNode : usesNode.getTargetUnknownNodes()) {
}
}
if (!exists) {
- UnknownSchemaNodeBuilder copy = CopyUtils.copy(childNode, usesNode.getParent(), true);
+ UnknownSchemaNodeBuilder copy = CopyUtils.copy(childNode, parent, true);
collection.add(copy);
}
}
throw new YangParseException(moduleName, lineNumber,
"Unknown member of target grouping while resolving uses node.");
}
- if (newChild instanceof GroupingMember) {
- ((GroupingMember) newChild).setAddedByUses(true);
- }
+ ((GroupingMember) newChild).setAddedByUses(true);
newChildren.add(newChild);
}
}
private static void correctNodePathForUsesNodes(final SchemaNodeBuilder node, final SchemaPath parentSchemaPath,
final ModuleBuilder parentModule) {
// set correct path
- List<QName> targetNodePath = new ArrayList<QName>(parentSchemaPath.getPath());
+ List<QName> targetNodePath = new ArrayList<>(parentSchemaPath.getPath());
targetNodePath.add(new QName(parentModule.getNamespace(), parentModule.getRevision(), parentModule.getPrefix(),
node.getQName().getLocalName()));
node.setPath(new SchemaPath(targetNodePath, true));
* already performed.
*
* @param usesNode
+ * uses node containing refine statements
*/
public static void performRefine(UsesNodeBuilder usesNode) {
for (RefineHolder refine : usesNode.getRefines()) {
private final String errorAppTag;
private final String errorMessage;
- MustDefinitionImpl(String mustStr, String description, String reference,
- String errorAppTag, String errorMessage) {
+ MustDefinitionImpl(String mustStr, String description, String reference, String errorAppTag, String errorMessage) {
this.mustStr = mustStr;
this.description = description;
this.reference = reference;
final int prime = 31;
int result = 1;
result = prime * result + ((mustStr == null) ? 0 : mustStr.hashCode());
- result = prime * result
- + ((description == null) ? 0 : description.hashCode());
- result = prime * result
- + ((reference == null) ? 0 : reference.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((reference == null) ? 0 : reference.hashCode());
return result;
}
import org.opendaylight.yangtools.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder;
-import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceBuilder;
import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceCaseBuilder;
import org.opendaylight.yangtools.yang.parser.builder.impl.ConstraintsBuilder;
import org.opendaylight.yangtools.yang.parser.builder.impl.UnionTypeBuilder;
ParseTree statusArg = ctx.getChild(i);
if (statusArg instanceof Status_argContext) {
String statusArgStr = stringFromNode(statusArg);
- if ("current".equals(statusArgStr)) {
+ switch (statusArgStr) {
+ case "current":
result = Status.CURRENT;
- } else if ("deprecated".equals(statusArgStr)) {
+ break;
+ case "deprecated":
result = Status.DEPRECATED;
- } else if ("obsolete".equals(statusArgStr)) {
+ break;
+ case "obsolete":
result = Status.OBSOLETE;
- } else {
+ break;
+ default:
LOG.warn("Invalid 'status' statement: " + statusArgStr);
}
}
* @return SchemaPath object
*/
public static SchemaPath createActualSchemaPath(final Stack<QName> actualPath) {
- final List<QName> path = new ArrayList<QName>(actualPath);
+ final List<QName> path = new ArrayList<>(actualPath);
return new SchemaPath(path, true);
}
*/
public static List<QName> createListKey(final String keyDefinition, final URI namespace, final Date revision,
final String prefix) {
- List<QName> key = new ArrayList<QName>();
+ List<QName> key = new ArrayList<>();
String[] splittedKey = keyDefinition.split(" ");
- QName qname = null;
+ QName qname;
for (String keyElement : splittedKey) {
if (keyElement.length() != 0) {
qname = new QName(namespace, revision, prefix, keyElement);
*/
private static List<EnumTypeDefinition.EnumPair> getEnumConstants(final Type_body_stmtsContext ctx,
final Stack<QName> path, final String moduleName) {
- List<EnumTypeDefinition.EnumPair> enumConstants = new ArrayList<EnumTypeDefinition.EnumPair>();
+ List<EnumTypeDefinition.EnumPair> enumConstants = new ArrayList<>();
for (int i = 0; i < ctx.getChildCount(); i++) {
ParseTree enumSpecChild = ctx.getChild(i);
* enum statement context
* @param highestValue
* current highest value in enumeration
- * @param path
+ * @param actualPath
* actual position in YANG model
* @param moduleName
* current module name
* @param ctx
* type body context to parse
* @param moduleName
+ * name of current module
* @return List of RangeConstraint created from this context
*/
private static List<RangeConstraint> getRangeConstraints(final Type_body_stmtsContext ctx, final String moduleName) {
* @param ctx
* range context to parse
* @param moduleName
+ * name of current module
* @return List of RangeConstraints parsed from this context
*/
private static List<RangeConstraint> parseRangeConstraints(final Range_stmtContext ctx, final String moduleName) {
final int line = ctx.getStart().getLine();
- List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();
+ List<RangeConstraint> rangeConstraints = new ArrayList<>();
String description = null;
String reference = null;
* @param ctx
* type body context to parse
* @param moduleName
+ * name of current module
* @return List of LengthConstraint created from this context
*/
private static List<LengthConstraint> getLengthConstraints(final Type_body_stmtsContext ctx, final String moduleName) {
* @param ctx
* length context to parse
* @param moduleName
+ * name of current module
* @return List of LengthConstraints parsed from this context
*/
private static List<LengthConstraint> parseLengthConstraints(final Length_stmtContext ctx, final String moduleName) {
final int line = ctx.getStart().getLine();
- List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();
+ List<LengthConstraint> lengthConstraints = new ArrayList<>();
String description = null;
String reference = null;
* type is one of special YANG values 'min' or 'max'
*/
private static Number parseNumberConstraintValue(final String value, final String moduleName, final int line) {
- Number result = null;
+ Number result;
if ("min".equals(value) || "max".equals(value)) {
result = new UnknownBoundaryNumber(value);
} else {
* @return list of pattern constraints
*/
private static List<PatternConstraint> getPatternConstraint(final Type_body_stmtsContext ctx) {
- List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();
+ List<PatternConstraint> patterns = new ArrayList<>();
for (int i = 0; i < ctx.getChildCount(); i++) {
ParseTree stringRestrChild = ctx.getChild(i);
*/
private static List<BitsTypeDefinition.Bit> getBits(Type_body_stmtsContext ctx, Stack<QName> actualPath,
String moduleName) {
- final List<BitsTypeDefinition.Bit> bits = new ArrayList<BitsTypeDefinition.Bit>();
+ final List<BitsTypeDefinition.Bit> bits = new ArrayList<>();
for (int j = 0; j < ctx.getChildCount(); j++) {
ParseTree bitsSpecChild = ctx.getChild(j);
if (bitsSpecChild instanceof Bits_specificationContext) {
ParseTree orderArg = ctx.getChild(j);
if (orderArg instanceof Ordered_by_argContext) {
String orderStr = stringFromNode(orderArg);
- if ("system".equals(orderStr)) {
+ switch (orderStr) {
+ case "system":
result = false;
- } else if ("user".equals(orderStr)) {
+ break;
+ case "user":
result = true;
- } else {
+ break;
+ default:
LOG.warn("Invalid 'ordered-by' statement.");
}
}
* @return config statement parsed from given context
*/
public static Boolean getConfig(final ParseTree ctx, final Builder parent, final String moduleName, final int line) {
- Boolean result = null;
+ Boolean result;
// parse configuration statement
Boolean config = null;
for (int i = 0; i < ctx.getChildCount(); i++) {
// If the parent node is a rpc input or output, it can has
// config set to null
result = parentConfig == null ? true : parentConfig;
- } else if (parent instanceof ChoiceCaseBuilder) {
- // If the parent node is a 'case' node, the value is the same as
- // the 'case' node's parent 'choice' node
- ChoiceCaseBuilder choiceCase = (ChoiceCaseBuilder) parent;
- Builder choice = choiceCase.getParent();
- Boolean parentConfig = null;
- if (choice instanceof ChoiceBuilder) {
- parentConfig = ((ChoiceBuilder) choice).isConfiguration();
- } else {
- parentConfig = true;
- }
- result = parentConfig;
} else {
result = true;
}
final ParseTree configContext = ctx.getChild(i);
if (configContext instanceof Config_argContext) {
final String value = stringFromNode(configContext);
- if ("true".equals(value)) {
+ switch (value) {
+ case "true":
result = true;
break;
- } else if ("false".equals(value)) {
+ case "false":
result = false;
break;
- } else {
+ default:
throw new YangParseException(moduleName, ctx.getStart().getLine(),
"Failed to parse 'config' statement value: '" + value + "'.");
}
* @param ctx
* type body
* @param actualPath
+ * actual path in model
* @param namespace
+ * module namespace
* @param revision
+ * module revision
* @param prefix
+ * module prefix
* @param parent
+ * current node parent
* @return UnknownType object with constraints from parsed type body
*/
public static TypeDefinition<?> parseUnknownTypeWithBody(final QName typedefQName,
return unknownType.build();
} else {
TypeDefinition<?> baseType = unknownType.build();
- TypeDefinition<?> result = null;
QName qname = new QName(namespace, revision, prefix, typeName);
SchemaPath schemaPath = createTypePath(actualPath, typeName);
typeBuilder.lengths(lengthStatements);
typeBuilder.patterns(patternStatements);
typeBuilder.fractionDigits(fractionDigits);
- result = typeBuilder.build();
- return result;
+ return typeBuilder.build();
}
}
baseType = decimalType;
} else if (typeName.startsWith("int")) {
IntegerTypeDefinition intType = null;
- if ("int8".equals(typeName)) {
+ switch (typeName) {
+ case "int8":
intType = Int8.getInstance();
- } else if ("int16".equals(typeName)) {
+ break;
+ case "int16":
intType = Int16.getInstance();
- } else if ("int32".equals(typeName)) {
+ break;
+ case "int32":
intType = Int32.getInstance();
- } else if ("int64".equals(typeName)) {
+ break;
+ case "int64":
intType = Int64.getInstance();
+ break;
}
if (intType == null) {
throw new YangParseException(moduleName, line, "Unknown yang type " + typeName);
baseType = intType;
} else if (typeName.startsWith("uint")) {
UnsignedIntegerTypeDefinition uintType = null;
- if ("uint8".equals(typeName)) {
+ switch (typeName) {
+ case "uint8":
uintType = Uint8.getInstance();
- } else if ("uint16".equals(typeName)) {
+ break;
+ case "uint16":
uintType = Uint16.getInstance();
- } else if ("uint32".equals(typeName)) {
+ break;
+ case "uint32":
uintType = Uint32.getInstance();
- } else if ("uint64".equals(typeName)) {
+ break;
+ case "uint64":
uintType = Uint64.getInstance();
+ break;
}
if (uintType == null) {
throw new YangParseException(moduleName, line, "Unknown yang type " + typeName);
return baseType;
}
- TypeDefinition<?> result = null;
- ExtendedType.Builder typeBuilder = null;
-
- List<QName> path = new ArrayList<QName>(actualPath);
+ List<QName> path = new ArrayList<>(actualPath);
path.add(new QName(namespace, revision, prefix, typeName));
SchemaPath schemaPath = new SchemaPath(path, true);
QName qname = schemaPath.getPath().get(schemaPath.getPath().size() - 1);
- typeBuilder = new ExtendedType.Builder(qname, baseType, "", "", schemaPath);
+ ExtendedType.Builder typeBuilder = new ExtendedType.Builder(qname, baseType, "", "", schemaPath);
typeBuilder.ranges(constraints.getRange());
typeBuilder.lengths(constraints.getLength());
typeBuilder.patterns(constraints.getPatterns());
typeBuilder.fractionDigits(constraints.getFractionDigits());
- result = typeBuilder.build();
- return result;
+ return typeBuilder.build();
}
private static SchemaPath createTypePath(Stack<QName> actual, String typeName) {
QName last = actual.peek();
QName typeQName = new QName(last.getNamespace(), last.getRevision(), last.getPrefix(), typeName);
- List<QName> path = new ArrayList<QName>(actual);
+ List<QName> path = new ArrayList<>(actual);
path.add(typeQName);
return new SchemaPath(path, true);
}
private static SchemaPath createBaseTypePath(Stack<QName> actual, String typeName) {
- List<QName> path = new ArrayList<QName>(actual);
+ List<QName> path = new ArrayList<>(actual);
path.add(BaseTypes.constructQName(typeName));
return new SchemaPath(path, true);
}
String prefix, String typeName) {
QName extTypeName = new QName(namespace, revision, prefix, typeName);
QName baseTypeName = BaseTypes.constructQName(typeName);
- List<QName> path = new ArrayList<QName>(actual);
+ List<QName> path = new ArrayList<>(actual);
path.add(extTypeName);
path.add(baseTypeName);
return new SchemaPath(path, true);
}
}
- MustDefinition must = new MustDefinitionImpl(mustText.toString(), description, reference, errorAppTag,
- errorMessage);
- return must;
+ return new MustDefinitionImpl(mustText.toString(), description, reference, errorAppTag, errorMessage);
}
/**
* informations in its body
*/
public static void checkMissingBody(final String typeName, final String moduleName, final int line) {
- if ("decimal64".equals(typeName)) {
+ switch (typeName) {
+ case "decimal64":
throw new YangParseException(moduleName, line,
"The 'fraction-digits' statement MUST be present if the type is 'decimal64'.");
- } else if ("identityref".equals(typeName)) {
+ case "identityref":
throw new YangParseException(moduleName, line,
"The 'base' statement MUST be present if the type is 'identityref'.");
- } else if ("leafref".equals(typeName)) {
+ case "leafref":
throw new YangParseException(moduleName, line,
"The 'path' statement MUST be present if the type is 'leafref'.");
- } else if ("bits".equals(typeName)) {
+ case "bits":
throw new YangParseException(moduleName, line, "The 'bit' statement MUST be present if the type is 'bits'.");
- } else if ("enumeration".equals(typeName)) {
+ case "enumeration":
throw new YangParseException(moduleName, line,
"The 'enum' statement MUST be present if the type is 'enumeration'.");
}
}
}
- public static void refineContainer(ContainerSchemaNodeBuilder container, RefineHolder refine, int line) {
+ public static void refineContainer(ContainerSchemaNodeBuilder container, RefineHolder refine) {
Boolean presence = refine.isPresence();
MustDefinition must = refine.getMust();
List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
}
}
- public static void refineList(ListSchemaNodeBuilder list, RefineHolder refine, int line) {
+ public static void refineList(ListSchemaNodeBuilder list, RefineHolder refine) {
MustDefinition must = refine.getMust();
Integer min = refine.getMinElements();
Integer max = refine.getMaxElements();
}
}
- public static void refineLeafList(LeafListSchemaNodeBuilder leafList, RefineHolder refine, int line) {
+ public static void refineLeafList(LeafListSchemaNodeBuilder leafList, RefineHolder refine) {
MustDefinition must = refine.getMust();
Integer min = refine.getMinElements();
Integer max = refine.getMaxElements();
}
}
- public static void refineChoice(ChoiceBuilder choice, RefineHolder refine, int line) {
+ public static void refineChoice(ChoiceBuilder choice, RefineHolder refine) {
String defaultStr = refine.getDefaultStr();
Boolean mandatory = refine.isMandatory();
List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
}
}
- public static void refineAnyxml(AnyXmlBuilder anyXml, RefineHolder refine, int line) {
+ public static void refineAnyxml(AnyXmlBuilder anyXml, RefineHolder refine) {
Boolean mandatory = refine.isMandatory();
MustDefinition must = refine.getMust();
List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
* refine object containing information about refine process
*/
public static void performRefine(SchemaNodeBuilder nodeToRefine, RefineHolder refine) {
- final int line = refine.getLine();
checkRefine(nodeToRefine, refine);
refineDefault(nodeToRefine, refine);
if (nodeToRefine instanceof LeafSchemaNodeBuilder) {
refineLeaf((LeafSchemaNodeBuilder) nodeToRefine, refine);
} else if (nodeToRefine instanceof ContainerSchemaNodeBuilder) {
- refineContainer((ContainerSchemaNodeBuilder) nodeToRefine, refine, line);
+ refineContainer((ContainerSchemaNodeBuilder) nodeToRefine, refine);
} else if (nodeToRefine instanceof ListSchemaNodeBuilder) {
- refineList((ListSchemaNodeBuilder) nodeToRefine, refine, line);
+ refineList((ListSchemaNodeBuilder) nodeToRefine, refine);
} else if (nodeToRefine instanceof LeafListSchemaNodeBuilder) {
- refineLeafList((LeafListSchemaNodeBuilder) nodeToRefine, refine, line);
+ refineLeafList((LeafListSchemaNodeBuilder) nodeToRefine, refine);
} else if (nodeToRefine instanceof ChoiceBuilder) {
- refineChoice((ChoiceBuilder) nodeToRefine, refine, line);
+ refineChoice((ChoiceBuilder) nodeToRefine, refine);
} else if (nodeToRefine instanceof AnyXmlBuilder) {
- refineAnyxml((AnyXmlBuilder) nodeToRefine, refine, line);
+ refineAnyxml((AnyXmlBuilder) nodeToRefine, refine);
}
}
public final class TypeConstraints {
private final String moduleName;
private final int line;
- private final List<List<RangeConstraint>> ranges = new ArrayList<List<RangeConstraint>>();
- private final List<List<LengthConstraint>> lengths = new ArrayList<List<LengthConstraint>>();
- private final List<List<PatternConstraint>> patterns = new ArrayList<List<PatternConstraint>>();
- private final List<Integer> fractionDigits = new ArrayList<Integer>();
+ private final List<List<RangeConstraint>> ranges = new ArrayList<>();
+ private final List<List<LengthConstraint>> lengths = new ArrayList<>();
+ private final List<List<PatternConstraint>> patterns = new ArrayList<>();
+ private final List<Integer> fractionDigits = new ArrayList<>();
public TypeConstraints(final String moduleName, final int line) {
this.moduleName = moduleName;
this.line = line;
}
- List<List<RangeConstraint>> getAllRanges() {
- return ranges;
- }
-
public List<RangeConstraint> getRange() {
if (ranges.size() < 2) {
return Collections.emptyList();
*/
package org.opendaylight.yangtools.yang.parser.util;
-import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.*;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findModuleFromBuilders;
+import static org.opendaylight.yangtools.yang.parser.util.ParserUtils.findModuleFromContext;
import java.util.ArrayList;
import java.util.Date;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.*;
+import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.ExtendedType;
import org.opendaylight.yangtools.yang.model.util.UnknownType;
import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
public static void resolveTypeUnion(final UnionTypeBuilder union,
final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder builder) {
final List<TypeDefinition<?>> unionTypes = union.getTypes();
- final List<TypeDefinition<?>> toRemove = new ArrayList<TypeDefinition<?>>();
+ final List<TypeDefinition<?>> toRemove = new ArrayList<>();
for (TypeDefinition<?> unionType : unionTypes) {
if (unionType instanceof UnknownType) {
final ModuleBuilder dependentModule = findModuleFromBuilders(modules, builder, unionType.getQName()
/**
* Resolve union type which contains one or more unresolved types.
- *
+ *
* @param union
* union type builder to resolve
* @param modules
final Map<String, TreeMap<Date, ModuleBuilder>> modules, final ModuleBuilder module,
final SchemaContext context) {
final List<TypeDefinition<?>> unionTypes = union.getTypes();
- final List<TypeDefinition<?>> toRemove = new ArrayList<TypeDefinition<?>>();
+ final List<TypeDefinition<?>> toRemove = new ArrayList<>();
for (TypeDefinition<?> unionType : unionTypes) {
if (unionType instanceof UnknownType) {
resolveUnionUnknownType(union, (UnknownType) unionType, modules, module, context);
super(errorMsg, exception);
}
- public YangParseException(final String moduleName, final int line,
- final String errorMsg) {
- super("Error in module '" + moduleName + "' at line " + line + ": "
- + errorMsg);
+ public YangParseException(final String moduleName, final int line, final String errorMsg) {
+ super("Error in module '" + moduleName + "' at line " + line + ": " + errorMsg);
}
- public YangParseException(final String moduleName, final int line,
- final String errorMsg, final Exception exception) {
- super("Error in module '" + moduleName + "' at line " + line + ": "
- + errorMsg, exception);
+ public YangParseException(final String moduleName, final int line, final String errorMsg, final Exception exception) {
+ super("Error in module '" + moduleName + "' at line " + line + ": " + errorMsg, exception);
}
}
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.util.BaseTypes;
-import com.google.common.collect.Lists;
-
public class AugmentTest {
private final URI types1NS = URI.create("urn:simple.nodes.test");
@Test
public void testAugmentParsing() {
- SchemaPath expectedPath = null;
- QName[] qnames = null;
+ SchemaPath expectedSchemaPath;
+ QName[] qnames = new QName[3];
+ qnames[0] = q0;
+ qnames[1] = q1;
+ qnames[2] = q2;
// testfile1
Module module1 = TestUtils.findModule(modules, "nodes");
Set<AugmentationSchema> augmentations = module1.getAugmentations();
assertEquals(1, augmentations.size());
AugmentationSchema augment = augmentations.iterator().next();
+ assertNotNull(augment);
+
+ expectedSchemaPath = new SchemaPath(Arrays.asList(qnames), true);
+ assertEquals(expectedSchemaPath, augment.getTargetPath());
Set<DataSchemaNode> augmentChildren = augment.getChildNodes();
assertEquals(5, augmentChildren.size());
// leaf ds0ChannelNumber
qnames[3] = new QName(types1NS, types1Rev, t1, "ds0ChannelNumber");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
- assertEquals(expectedPath, ds0ChannelNumber.getPath());
+ expectedSchemaPath = new SchemaPath(Arrays.asList(qnames), true);
+ assertEquals(expectedSchemaPath, ds0ChannelNumber.getPath());
+ assertFalse(ds0ChannelNumber.isAugmenting());
// type of leaf ds0ChannelNumber
QName typeQName = BaseTypes.constructQName("string");
List<QName> typePath = Collections.singletonList(typeQName);
- expectedPath = new SchemaPath(typePath, true);
- assertEquals(expectedPath, ds0ChannelNumber.getType().getPath());
+ expectedSchemaPath = new SchemaPath(typePath, true);
+ assertEquals(expectedSchemaPath, ds0ChannelNumber.getType().getPath());
// leaf interface-id
qnames[3] = new QName(types1NS, types1Rev, t1, "interface-id");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
- assertEquals(expectedPath, interfaceId.getPath());
+ expectedSchemaPath = new SchemaPath(Arrays.asList(qnames), true);
+ assertEquals(expectedSchemaPath, interfaceId.getPath());
+ assertFalse(interfaceId.isAugmenting());
// leaf my-type
qnames[3] = new QName(types1NS, types1Rev, t1, "my-type");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
- assertEquals(expectedPath, myType.getPath());
+ expectedSchemaPath = new SchemaPath(Arrays.asList(qnames), true);
+ assertEquals(expectedSchemaPath, myType.getPath());
+ assertFalse(myType.isAugmenting());
// container schemas
qnames[3] = new QName(types1NS, types1Rev, t1, "schemas");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
- assertEquals(expectedPath, schemas.getPath());
+ expectedSchemaPath = new SchemaPath(Arrays.asList(qnames), true);
+ assertEquals(expectedSchemaPath, schemas.getPath());
+ assertFalse(schemas.isAugmenting());
// choice odl
qnames[3] = new QName(types1NS, types1Rev, t1, "odl");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
- assertEquals(expectedPath, odl.getPath());
+ expectedSchemaPath = new SchemaPath(Arrays.asList(qnames), true);
+ assertEquals(expectedSchemaPath, odl.getPath());
+ assertFalse(odl.isAugmenting());
// testfile3
Module module3 = TestUtils.findModule(modules, "custom");
@Test
public void testAugmentResolving() throws ParseException {
- SchemaPath expectedPath = null;
- QName[] qnames = null;
-
Module module2 = TestUtils.findModule(modules, "types");
ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName("interfaces");
ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
assertNotNull(schemas);
assertNotNull(odl);
- qnames = new QName[4];
+ SchemaPath expectedPath;
+ QName[] qnames = new QName[4];
qnames[0] = q0;
qnames[1] = q1;
qnames[2] = q2;
// leaf ds0ChannelNumber
qnames[3] = new QName(types1NS, types1Rev, t1, "ds0ChannelNumber");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, ds0ChannelNumber.getPath());
// leaf interface-id
qnames[3] = new QName(types1NS, types1Rev, t1, "interface-id");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, interfaceId.getPath());
// leaf my-type
qnames[3] = new QName(types1NS, types1Rev, t1, "my-type");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, myType.getPath());
// container schemas
qnames[3] = new QName(types1NS, types1Rev, t1, "schemas");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, schemas.getPath());
// choice odl
qnames[3] = new QName(types1NS, types1Rev, t1, "odl");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, odl.getPath());
}
@Test
public void testAugmentChoice() throws ParseException {
- SchemaPath expectedPath = null;
- QName[] qnames = null;
-
Module module2 = TestUtils.findModule(modules, "types");
ContainerSchemaNode interfaces = (ContainerSchemaNode) module2.getDataChildByName("interfaces");
ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName("ifEntry");
assertNotNull(node2);
assertNotNull(node3);
- qnames = new QName[5];
+ SchemaPath expectedPath;
+ QName[] qnames = new QName[5];
qnames[0] = q0;
qnames[1] = q1;
qnames[2] = q2;
// case id
qnames[4] = new QName(types1NS, types1Rev, t1, "id");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, id.getPath());
Set<DataSchemaNode> idChildren = id.getChildNodes();
assertEquals(1, idChildren.size());
// case node1
qnames[4] = new QName(types1NS, types1Rev, t1, "node1");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, node1.getPath());
Set<DataSchemaNode> node1Children = node1.getChildNodes();
assertTrue(node1Children.isEmpty());
// case node2
qnames[4] = new QName(types1NS, types1Rev, t1, "node2");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, node2.getPath());
Set<DataSchemaNode> node2Children = node2.getChildNodes();
assertTrue(node2Children.isEmpty());
// case node3
qnames[4] = new QName(types1NS, types1Rev, t1, "node3");
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, node3.getPath());
Set<DataSchemaNode> node3Children = node3.getChildNodes();
assertEquals(1, node3Children.size());
qnames[5] = new QName(types1NS, types1Rev, t1, "id");
LeafSchemaNode caseIdChild = (LeafSchemaNode) idChildren.iterator().next();
assertNotNull(caseIdChild);
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, caseIdChild.getPath());
// case node3 child
qnames[5] = new QName(types1NS, types1Rev, t1, "node3");
ContainerSchemaNode caseNode3Child = (ContainerSchemaNode) node3Children.iterator().next();
assertNotNull(caseNode3Child);
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, caseNode3Child.getPath());
}
assertTrue(create.isAugmenting());
assertTrue(destroy.isAugmenting());
- SchemaPath expectedPath = null;
+ SchemaPath expectedPath;
QName[] qnames = new QName[4];
qnames[0] = submitQName;
qnames[1] = inputQName;
// case attach
qnames[3] = new QName(NS_FOO, revision, "f", "attach");
assertEquals(qnames[3], attach.getQName());
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, attach.getPath());
Set<DataSchemaNode> attachChildren = attach.getChildNodes();
assertEquals(1, attachChildren.size());
// case create
qnames[3] = new QName(NS_FOO, revision, "f", "create");
assertEquals(qnames[3], create.getQName());
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, create.getPath());
Set<DataSchemaNode> createChildren = create.getChildNodes();
assertEquals(1, createChildren.size());
// case attach
qnames[3] = new QName(NS_FOO, revision, "f", "destroy");
assertEquals(qnames[3], destroy.getQName());
- expectedPath = new SchemaPath(Lists.newArrayList(qnames), true);
+ expectedPath = new SchemaPath(Arrays.asList(qnames), true);
assertEquals(expectedPath, destroy.getPath());
Set<DataSchemaNode> destroyChildren = destroy.getChildNodes();
assertEquals(1, destroyChildren.size());
module bar {
yang-version 1;
namespace "urn:opendaylight:bar";
- prefix "b";
+ prefix "bar";
revision "2013-10-11" {
}
module foo {
yang-version 1;
namespace "urn:opendaylight:foo";
- prefix "f";
+ prefix "foo";
import bar { prefix b; revision-date 2013-10-11; }
revision "2013-10-11" {
}
- augment "/b:submit/b:input/b:arguments" {
+ augment "/b:submit/b:input/b:arguments" {
when "../type = attach-path-instruction";
case attach {