*/
package org.opendaylight.controller.yang.parser.builder.api;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.DataSchemaNode;
import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.util.YangParseException;
+/**
+ * Basic implementation of DataNodeContainerBuilder.
+ */
public abstract class AbstractDataNodeContainerBuilder implements DataNodeContainerBuilder {
protected final int line;
protected final QName qname;
protected Set<GroupingDefinition> groupings;
protected final Set<GroupingBuilder> addedGroupings = new HashSet<GroupingBuilder>();
+ protected List<UnknownSchemaNode> unknownNodes;
+ protected final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
+
protected AbstractDataNodeContainerBuilder(final int line, final QName qname) {
this.line = line;
this.qname = qname;
addedGroupings.add(groupingBuilder);
}
+ @Override
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
+ return addedUnknownNodes;
+ }
+
+ @Override
+ public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {
+ addedUnknownNodes.add(unknownNode);
+ }
+
+ public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {
+ this.unknownNodes = unknownNodes;
+ }
+
}
}\r
\r
@Override\r
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {\r
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {\r
+ return addedUnknownNodes;\r
+ }\r
+\r
+ @Override\r
+ public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {\r
addedUnknownNodes.add(unknownNode);\r
}\r
\r
*/
package org.opendaylight.controller.yang.parser.builder.api;
+import java.util.ArrayList;
+import java.util.List;
+
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
/**
* Basic implementation for TypeAwareBuilder builders.
protected Builder parent;
protected TypeDefinition<?> type;
protected TypeDefinitionBuilder typedef;
+ protected List<UnknownSchemaNode> unknownNodes;
+ protected final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
public AbstractTypeAwareBuilder(final int line, final QName qname) {
this.line = line;
this.type = null;
}
+ @Override
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
+ return addedUnknownNodes;
+ }
+
+ @Override
+ public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {
+ addedUnknownNodes.add(unknownNode);
+ }
+
+ public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {
+ this.unknownNodes = unknownNodes;
+ }
+
}
*/
public interface AugmentationSchemaBuilder extends DataNodeContainerBuilder {
- Builder getParent();
-
String getWhenCondition();
void addWhenCondition(String whenCondition);
*/
package org.opendaylight.controller.yang.parser.builder.api;
+import java.util.List;
+
import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
/**
*/
void setParent(Builder parent);
+ /**
+ * Add unknown node to this builder.
+ *
+ * @param unknownNode
+ */
+ void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode);
+
+ /**
+ * Get builders of unknown nodes defined in this node.
+ *
+ * @return collection of UnknownSchemaNodeBuilder objects
+ */
+ List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders();
+
/**
* Build YANG data model node.
*
*/
Object build();
- void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode);
-
}
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.yang.parser.builder.api;
-
-/**
- * Interface for all nodes which can have 'config' statement.
- * [container, leaf, leaf-list, list, choice, anyxml, deviate]
- *
- */
-public interface ConfigNode {
-
- Boolean isConfiguration();
-
- void setConfiguration(Boolean config);
-
-}
*/
public interface DataNodeContainerBuilder extends Builder {
+ /**
+ * Get qname of this node.
+ *
+ * @return QName of this node
+ */
QName getQName();
+ /**
+ * Get schema path of this node.
+ *
+ * @return SchemaPath of this node
+ */
SchemaPath getPath();
+ /**
+ * Get already built child nodes.
+ *
+ * @return collection of child nodes
+ */
Set<DataSchemaNode> getChildNodes();
+ /**
+ * Get builders of child nodes.
+ *
+ * @return collection child nodes builders
+ */
Set<DataSchemaNodeBuilder> getChildNodeBuilders();
+ /**
+ * Get child node by name.
+ *
+ * @param name
+ * name of child to seek
+ * @return child node with given name if present, null otherwise
+ */
DataSchemaNodeBuilder getDataChildByName(String name);
+ /**
+ * Add builder of child node to this node.
+ *
+ * @param childNode
+ */
void addChildNode(DataSchemaNodeBuilder childNode);
+ /**
+ * Get already built groupings defined in this node.
+ *
+ * @return collection of GroupingDefinition objects
+ */
Set<GroupingDefinition> getGroupings();
+ /**
+ * Get builders of groupings defined in this node.
+ *
+ * @return collection of grouping builders
+ */
Set<GroupingBuilder> getGroupingBuilders();
+ /**
+ * Add builder of grouping statement to this node.
+ *
+ * @param groupingBuilder
+ */
void addGrouping(GroupingBuilder groupingBuilder);
+ /**
+ * Add builder of uses statement to this node.
+ *
+ * @param usesBuilder
+ */
void addUsesNode(UsesNodeBuilder usesBuilder);
+ /**
+ * Get builders of typedef statement defined in this node.
+ *
+ * @return
+ */
Set<TypeDefinitionBuilder> getTypeDefinitionBuilders();
+ /**
+ * Add typedef builder to this node.
+ *
+ * @param typedefBuilder
+ */
void addTypedef(TypeDefinitionBuilder typedefBuilder);
}
*/
public interface DataSchemaNodeBuilder extends SchemaNodeBuilder {
+ /**
+ * Build DataSchemaNode object from this builder.
+ */
DataSchemaNode build();
+ /**
+ *
+ * @return true, if this node is added by augmentation, false otherwise
+ */
boolean isAugmenting();
+ /**
+ * Set if this node is added by augmentation.
+ *
+ * @param augmenting
+ */
void setAugmenting(boolean augmenting);
+ /**
+ * Get value of config statement.
+ *
+ * @return value of config statement
+ */
+ Boolean isConfiguration();
+
+ /**
+ * Set config statement.
+ *
+ * @param config
+ */
+ void setConfiguration(Boolean config);
+
+ /**
+ * Get constraints of this builder.
+ *
+ * @return constraints of this builder
+ */
ConstraintsBuilder getConstraints();
}
*/
package org.opendaylight.controller.yang.parser.builder.api;
-import java.util.List;
import java.util.Set;
import org.opendaylight.controller.yang.model.api.GroupingDefinition;
-import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
/**
* Interface for builders of 'grouping' statement.
*/
public interface GroupingBuilder extends DataNodeContainerBuilder, SchemaNodeBuilder, GroupingMember {
+ /**
+ * Build GroupingDefinition object from this builder.
+ */
GroupingDefinition build();
- DataSchemaNodeBuilder getChildNode(String name);
-
- List<UnknownSchemaNodeBuilder> getUnknownNodes();
-
+ /**
+ * Get uses statement defined in this builder
+ *
+ * @return collection of builders of uses statements
+ */
Set<UsesNodeBuilder> getUses();
}
*/
public interface GroupingMember extends Builder {
+ /**
+ *
+ * @return true, if this node is added by uses statement, false otherwise
+ */
boolean isAddedByUses();
+ /**
+ * Set if this node is added by uses.
+ *
+ * @param addedByUses
+ */
void setAddedByUses(boolean addedByUses);
}
import org.opendaylight.controller.yang.model.api.SchemaNode;\r
import org.opendaylight.controller.yang.model.api.SchemaPath;\r
import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;\r
\r
/**\r
* Interface for all builders of SchemaNode nodes.\r
*/\r
public interface SchemaNodeBuilder extends Builder {\r
\r
+ /**\r
+ * Get qname of this node.\r
+ *\r
+ * @return QName of this node\r
+ */\r
QName getQName();\r
\r
+ /**\r
+ * Get schema path of this node.\r
+ *\r
+ * @return SchemaPath of this node\r
+ */\r
SchemaPath getPath();\r
\r
+ /**\r
+ * Set schema path to this node.\r
+ *\r
+ * @param schemaPath\r
+ */\r
void setPath(SchemaPath schemaPath);\r
\r
+ /**\r
+ * Get description of this node.\r
+ *\r
+ * @return description statement\r
+ */\r
String getDescription();\r
\r
+ /**\r
+ * Set description to this node.\r
+ *\r
+ * @param description\r
+ */\r
void setDescription(String description);\r
\r
+ /**\r
+ * Get reference of this node.\r
+ *\r
+ * @return reference statement\r
+ */\r
String getReference();\r
\r
+ /**\r
+ * Set reference to this node.\r
+ *\r
+ * @param reference\r
+ */\r
void setReference(String reference);\r
\r
+ /**\r
+ * Get status of this node.\r
+ *\r
+ * @return status statement\r
+ */\r
Status getStatus();\r
\r
+ /**\r
+ * Set status to this node.\r
+ *\r
+ * @param status\r
+ */\r
void setStatus(Status status);\r
\r
- void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode);\r
-\r
+ /**\r
+ * Build SchemaNode object from this builder.\r
+ */\r
SchemaNode build();\r
\r
}\r
import org.opendaylight.controller.yang.model.api.TypeDefinition;
/**
- * Builders of all nodes, which can have 'type' statement must implement this interface.
- * [typedef, type, leaf, leaf-list, deviate]
+ * Builders of all nodes, which can have 'type' statement must implement this
+ * interface. [typedef, type, leaf, leaf-list, deviate]
*/
public interface TypeAwareBuilder extends Builder {
+ /**
+ * Get qname of this node.
+ *
+ * @return QName of this node
+ */
QName getQName();
+ /**
+ * Get schema path of this node.
+ *
+ * @return SchemaPath of this node
+ */
SchemaPath getPath();
+ /**
+ * Get resolved type of this node.
+ *
+ * @return type of this node if it is already resolved, null otherwise
+ */
TypeDefinition<?> getType();
+ /**
+ * Get builder of type of this node.
+ *
+ * @return builder of type of this node or null of this builder has already
+ * resolved type
+ */
TypeDefinitionBuilder getTypedef();
+ /**
+ * Set resolved type to this node.
+ *
+ * @param type
+ * type to set
+ */
void setType(TypeDefinition<?> type);
+ /**
+ * Set builder of type to this node.
+ *
+ * @param typedef
+ * builder of type to set
+ */
void setTypedef(TypeDefinitionBuilder typedef);
}
import org.opendaylight.controller.yang.model.api.type.LengthConstraint;\r
import org.opendaylight.controller.yang.model.api.type.PatternConstraint;\r
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;\r
-import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;\r
\r
/**\r
* Interface for builders of 'typedef' statement.\r
\r
List<UnknownSchemaNode> getUnknownNodes();\r
\r
- List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders();\r
-\r
Object getDefaultValue();\r
\r
void setDefaultValue(Object defaultValue);\r
import org.opendaylight.controller.yang.model.api.Status;
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
import org.opendaylight.controller.yang.parser.builder.api.AbstractSchemaNodeBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingMember;
import org.opendaylight.controller.yang.parser.util.Comparators;
-public final class AnyXmlBuilder extends AbstractSchemaNodeBuilder implements DataSchemaNodeBuilder, GroupingMember,
- ConfigNode {
+public final class AnyXmlBuilder extends AbstractSchemaNodeBuilder implements DataSchemaNodeBuilder, GroupingMember {
private boolean built;
private final AnyXmlSchemaNodeImpl instance;
private final ConstraintsBuilder constraints;
private SchemaPath finalAugmentTarget;
private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
private boolean resolved;
AugmentationSchemaBuilderImpl(final int line, final String augmentTargetStr) {
return augmentTargetStr;
}
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
- return addedUnknownNodes;
- }
-
- @Override
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
@Override
public int hashCode() {
final int prime = 17;
import org.opendaylight.controller.yang.parser.builder.api.AbstractSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;
import org.opendaylight.controller.yang.parser.builder.api.AugmentationTargetBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingMember;
import org.opendaylight.controller.yang.parser.util.Comparators;
import org.opendaylight.controller.yang.parser.util.ParserUtils;
public final class ChoiceBuilder extends AbstractSchemaNodeBuilder implements DataSchemaNodeBuilder,
- AugmentationTargetBuilder, GroupingMember, ConfigNode {
+ AugmentationTargetBuilder, GroupingMember {
private boolean isBuilt;
private final ChoiceNodeImpl instance;
// DataSchemaNode args
public void addChildNode(DataSchemaNodeBuilder childNode) {
if (!(childNode instanceof ChoiceCaseBuilder)) {
ChoiceCaseBuilder caseBuilder = new ChoiceCaseBuilder(childNode.getLine(), childNode.getQName());
- if(childNode.isAugmenting()) {
+ if (childNode.isAugmenting()) {
caseBuilder.setAugmenting(true);
childNode.setAugmenting(false);
}
private String description;
private String reference;
private Status status = Status.CURRENT;
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
// DataSchemaNode args
private boolean augmenting;
private final ConstraintsBuilder constraints;
this.augmenting = augmenting;
}
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
- return addedUnknownNodes;
- }
-
- @Override
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
public Set<UsesNodeBuilder> getUsesNodes() {
return addedUsesNodes;
}
throw new YangParseException(line, "Can not add type definition to choice case.");
}
+ @Override
+ public Boolean isConfiguration() {
+ return false;
+ }
+
+ @Override
+ public void setConfiguration(final Boolean configuration) {
+ throw new YangParseException(line, "Can not add config statement to choice case.");
+ }
+
@Override
public ConstraintsBuilder getConstraints() {
return constraints;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
}
@Override
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
+ public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {
throw new YangParseException(line, "Can not add unknown node to constraints.");
}
+ @Override
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
+ return Collections.emptyList();
+ }
+
public Integer getMinElements() {
return min;
}
import org.opendaylight.controller.yang.parser.builder.api.AbstractDataNodeContainerBuilder;
import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;
import org.opendaylight.controller.yang.parser.builder.api.AugmentationTargetBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingMember;
import org.opendaylight.controller.yang.parser.util.Comparators;
public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerBuilder implements
- AugmentationTargetBuilder, DataSchemaNodeBuilder, GroupingMember, ConfigNode {
+ AugmentationTargetBuilder, DataSchemaNodeBuilder, GroupingMember {
private boolean isBuilt;
private final ContainerSchemaNodeImpl instance;
private String description;
private String reference;
private Status status = Status.CURRENT;
- private List<UnknownSchemaNode> unknownNodes;
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
// DataSchemaNode args
private boolean augmenting;
private boolean addedByUses;
augmentations = b.augmentations;
addedAugmentations.addAll(b.getAugmentations());
unknownNodes = b.unknownNodes;
- addedUnknownNodes.addAll(b.getUnknownNodes());
+ addedUnknownNodes.addAll(b.getUnknownNodeBuilders());
}
@Override
this.presence = presence;
}
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
- return addedUnknownNodes;
- }
-
- @Override
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
- public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {
- this.unknownNodes = unknownNodes;
- }
-
@Override
public int hashCode() {
final int prime = 31;
public final class DeviationBuilder implements Builder {
private final int line;
+ private final String targetPathStr;
private Builder parent;
private boolean isBuilt;
private final DeviationImpl instance;
throw new YangParseException(line, "Deviation argument string must be an absolute schema node identifier.");
}
this.line = line;
+ this.targetPathStr = targetPathStr;
this.targetPath = ParserListenerUtils.parseAugmentPath(targetPathStr);
instance = new DeviationImpl();
}
}
@Override
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
+ return addedUnknownNodes;
+ }
+
+ @Override
+ public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {
addedUnknownNodes.add(unknownNode);
}
this.reference = reference;
}
+ @Override
+ public String toString() {
+ return "deviation " + targetPathStr;
+ }
+
private final class DeviationImpl implements Deviation {
private SchemaPath targetPath;
private Deviate deviate;
instance.setArgument(argument);
}
+ @Override
+ public String toString() {
+ return "extension " + qname.getLocalName();
+ }
+
private final class ExtensionDefinitionImpl implements ExtensionDefinition {
private final QName qname;
private String argument;
return instance;
}
+ @Override
+ public String toString() {
+ return "feature " + qname.getLocalName();
+ }
+
private final class FeatureDefinitionImpl implements FeatureDefinition {
private final QName qname;
private SchemaPath path;
groupings = builder.getGroupings();
addedGroupings.addAll(builder.getGroupingBuilders());
addedUsesNodes.addAll(builder.getUses());
- addedUnknownNodes.addAll(builder.getUnknownNodes());
+ addedUnknownNodes.addAll(builder.getUnknownNodeBuilders());
}
@Override
this.addedByUses = addedByUses;
}
- @Override
- public DataSchemaNodeBuilder getChildNode(String name) {
- DataSchemaNodeBuilder result = null;
- for (DataSchemaNodeBuilder node : addedChildNodes) {
- if (node.getQName().getLocalName().equals(name)) {
- result = node;
- break;
- }
- }
- return result;
- }
-
@Override
public Set<DataSchemaNode> getChildNodes() {
return childNodes;
}
@Override
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
return addedUnknownNodes;
}
@Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
+ public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder unknownNode) {
addedUnknownNodes.add(unknownNode);
}
this.unknownNodes = unknownNodes;
}
+ @Override
+ public String toString() {
+ return "grouping " + qname.getLocalName();
+ }
+
private final class GroupingDefinitionImpl implements GroupingDefinition {
private final QName qname;
private SchemaPath path;
this.baseIdentity = baseType;
}
+ @Override
+ public String toString() {
+ return "identity " + qname.getLocalName();
+ }
+
private final class IdentitySchemaNodeImpl implements IdentitySchemaNode {
private final QName qname;
private IdentitySchemaNode baseIdentity;
}
@Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
+ public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder unknownNode) {
throw new YangParseException(line, "Can not add unknown node to " + NAME);
}
import org.opendaylight.controller.yang.model.api.TypeDefinition;
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingMember;
import org.opendaylight.controller.yang.parser.util.Comparators;
public final class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder implements DataSchemaNodeBuilder,
- GroupingMember, ConfigNode {
+ GroupingMember {
private boolean isBuilt;
private final LeafListSchemaNodeImpl instance;
// SchemaNode args
private String description;
private String reference;
private Status status = Status.CURRENT;
- private List<UnknownSchemaNode> unknownNodes;
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
// DataSchemaNode args
private boolean augmenting;
private boolean addedByUses;
configuration = b.isConfiguration();
userOrdered = b.isUserOrdered();
unknownNodes = b.unknownNodes;
- addedUnknownNodes.addAll(b.getUnknownNodes());
+ addedUnknownNodes.addAll(b.getUnknownNodeBuilders());
}
@Override
this.userOrdered = userOrdered;
}
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
- return addedUnknownNodes;
- }
-
- @Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
- public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {
- this.unknownNodes = unknownNodes;
- }
-
@Override
public int hashCode() {
final int prime = 31;
import org.opendaylight.controller.yang.model.api.TypeDefinition;
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
import org.opendaylight.controller.yang.parser.builder.api.AbstractTypeAwareBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingMember;
import org.opendaylight.controller.yang.parser.util.Comparators;
public final class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implements DataSchemaNodeBuilder,
- GroupingMember, ConfigNode {
+ GroupingMember {
private boolean isBuilt;
private final LeafSchemaNodeImpl instance;
// SchemaNode args
private String description;
private String reference;
private Status status = Status.CURRENT;
- private List<UnknownSchemaNode> unknownNodes;
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
// DataSchemaNode args
private boolean augmenting;
private boolean addedByUses;
addedByUses = b.isAddedByUses();
configuration = b.isConfiguration();
unknownNodes = b.unknownNodes;
- addedUnknownNodes.addAll(b.getUnknownNodes());
+ addedUnknownNodes.addAll(b.getUnknownNodeBuilders());
defaultStr = b.getDefaultStr();
unitsStr = b.getUnits();
return constraints;
}
- @Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
- return addedUnknownNodes;
- }
-
- public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {
- this.unknownNodes = unknownNodes;
- }
-
public String getDescription() {
return description;
}
import org.opendaylight.controller.yang.parser.builder.api.AbstractDataNodeContainerBuilder;
import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;
import org.opendaylight.controller.yang.parser.builder.api.AugmentationTargetBuilder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingBuilder;
import org.opendaylight.controller.yang.parser.builder.api.GroupingMember;
import org.opendaylight.controller.yang.parser.util.Comparators;
public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilder implements DataSchemaNodeBuilder,
- AugmentationTargetBuilder, GroupingMember, ConfigNode {
+ AugmentationTargetBuilder, GroupingMember {
private boolean isBuilt;
private final ListSchemaNodeImpl instance;
// SchemaNode args
private String description;
private String reference;
private Status status = Status.CURRENT;
- private List<UnknownSchemaNode> unknownNodes;
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
// DataSchemaNode args
private boolean augmenting;
private boolean addedByUses;
augmentations = b.augmentations;
addedAugmentations.addAll(b.getAugmentations());
unknownNodes = b.unknownNodes;
- addedUnknownNodes.addAll(b.getUnknownNodes());
+ addedUnknownNodes.addAll(b.getUnknownNodeBuilders());
}
@Override
this.userOrdered = userOrdered;
}
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
- return addedUnknownNodes;
- }
-
- @Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
- public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {
- this.unknownNodes = unknownNodes;
- }
-
@Override
public int hashCode() {
final int prime = 31;
private final Set<DeviationBuilder> addedDeviations = new HashSet<DeviationBuilder>();
private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
private final List<ExtensionBuilder> addedExtensions = new ArrayList<ExtensionBuilder>();
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
private final List<UnknownSchemaNodeBuilder> allUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
public ModuleBuilder(final String name) {
}
@Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder builder) {
+ public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder builder) {
addedUnknownNodes.add(builder);
allUnknownNodes.add(builder);
}
addedUnknownNodes.add(builder);
} else {
if (parent instanceof SchemaNodeBuilder) {
- ((SchemaNodeBuilder) parent).addUnknownSchemaNode(builder);
+ ((SchemaNodeBuilder) parent).addUnknownNodeBuilder(builder);
} else if (parent instanceof DataNodeContainerBuilder) {
- ((DataNodeContainerBuilder) parent).addUnknownSchemaNode(builder);
+ ((DataNodeContainerBuilder) parent).addUnknownNodeBuilder(builder);
} else if (parent instanceof RefineHolder) {
- ((RefineHolder) parent).addUnknownSchemaNode(builder);
+ ((RefineHolder) parent).addUnknownNodeBuilder(builder);
} else {
throw new YangParseException(name, line, "Unresolved parent of unknown node '" + qname.getLocalName()
+ "'");
private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
private Set<AugmentationSchema> augmentations;
private final Set<AugmentationSchemaBuilder> addedAugmentations = new HashSet<AugmentationSchemaBuilder>();
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
NotificationBuilder(final int line, final QName qname) {
super(line, qname);
this.augmentations = augmentations;
}
- @Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
@Override
public String toString() {
return "notification " + getQName().getLocalName();
public final class TypeDefinitionBuilderImpl extends AbstractTypeAwareBuilder implements TypeDefinitionBuilder {
private SchemaPath schemaPath;
- private List<UnknownSchemaNode> unknownNodes;
- private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
private List<RangeConstraint> ranges = Collections.emptyList();
private List<LengthConstraint> lengths = Collections.emptyList();
private List<PatternConstraint> patterns = Collections.emptyList();
return Collections.emptyList();
}
- @Override
- public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
- return addedUnknownNodes;
- }
-
- @Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
- addedUnknownNodes.add(unknownNode);
- }
-
- public void setUnknownNodes(List<UnknownSchemaNode> unknownNodes) {
- this.unknownNodes = unknownNodes;
- }
-
@Override
public List<RangeConstraint> getRanges() {
return ranges;
}
@Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
+ public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder unknownNode) {
// not yet supported
}
refines.add(refine);\r
}\r
\r
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {\r
+ @Override\r
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {\r
return addedUnknownNodes;\r
}\r
\r
@Override\r
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {\r
+ public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {\r
addedUnknownNodes.add(unknownNode);\r
}\r
\r
import com.google.common.collect.Sets;
public final class YangParserImpl implements YangModelParser {
- private static final Logger logger = LoggerFactory.getLogger(YangParserImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(YangParserImpl.class);
@Override
public Set<Module> parseYangModels(final List<File> yangFiles) {
try {
inputStreams.put(new FileInputStream(yangFile), yangFile);
} catch (FileNotFoundException e) {
- logger.warn("Exception while reading yang file: " + yangFile.getName(), e);
+ LOG.warn("Exception while reading yang file: " + yangFile.getName(), e);
}
}
try {
is.close();
} catch (IOException e) {
- logger.debug("Failed to close stream.");
+ LOG.debug("Failed to close stream.");
}
}
try {
inputStreams.put(new FileInputStream(yangFile), yangFile);
} catch (FileNotFoundException e) {
- logger.warn("Exception while reading yang file: " + yangFile.getName(), e);
+ LOG.warn("Exception while reading yang file: " + yangFile.getName(), e);
}
}
try {
is.close();
} catch (IOException e) {
- logger.debug("Failed to close stream.");
+ LOG.debug("Failed to close stream.");
}
}
result = parser.yang();
} catch (IOException e) {
- logger.warn("Exception while reading yang file: " + yangStream, e);
+ LOG.warn("Exception while reading yang file: " + yangStream, e);
}
return result;
}
// uses has not path
parent.addUsesNode(newUses);
}
- for (UnknownSchemaNodeBuilder un : targetGrouping.getUnknownNodes()) {
+ for (UnknownSchemaNodeBuilder un : targetGrouping.getUnknownNodeBuilders()) {
UnknownSchemaNodeBuilder newUn = new UnknownSchemaNodeBuilder(un);
newUn.setAddedByUses(true);
newUn.setPath(createSchemaPath(parentPath, un.getQName().getLocalName()));
- parent.addUnknownSchemaNode(newUn);
+ parent.addUnknownNodeBuilder(newUn);
}
}
UnknownSchemaNodeBuilder newNode = createUnknownSchemaNode(un, line);
newNode.setAddedByUses(true);
newNode.setPath(createSchemaPath(parentPath, un.getQName().getLocalName()));
- parent.addUnknownSchemaNode(newNode);
+ parent.addUnknownNodeBuilder(newNode);
}
}
nodeType.getPrefix(), nodeType.getLocalName());
usnb.setNodeType(newNodeType);
} catch (YangParseException e) {
- logger.debug(module.getName(), usnb.getLine(), "Failed to find unknown node type: " + nodeType);
+ LOG.debug(module.getName(), usnb.getLine(), "Failed to find unknown node type: " + nodeType);
}
}
}
unknownNodeBuilder.setNodeType(newNodeType);
} catch (YangParseException e) {
- logger.debug(module.getName(), unknownNodeBuilder.getLine(), "Failed to find unknown node type: "
+ LOG.debug(module.getName(), unknownNodeBuilder.getLine(), "Failed to find unknown node type: "
+ nodeType);
}
}
}
}
} else {
- type = parseUnknownTypeWithBody(typeQName, typeBody, actualPath, namespace, revision, yangModelPrefix,
+ type = parseUnknownTypeWithBody(moduleName, typeQName, typeBody, actualPath, namespace, revision, yangModelPrefix,
moduleBuilder.getActualNode());
// add parent node of this type statement to dirty nodes
moduleBuilder.markActualNodeDirty();
import org.opendaylight.controller.antlrv4.code.gen.YangParser.Error_message_stmtContext;
import org.opendaylight.controller.antlrv4.code.gen.YangParser.Fraction_digits_stmtContext;
import org.opendaylight.controller.antlrv4.code.gen.YangParser.Identityref_specificationContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Instance_identifier_specificationContext;
import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leafref_specificationContext;
import org.opendaylight.controller.antlrv4.code.gen.YangParser.Length_stmtContext;
import org.opendaylight.controller.antlrv4.code.gen.YangParser.Mandatory_argContext;
import org.opendaylight.controller.yang.model.util.Uint8;
import org.opendaylight.controller.yang.model.util.UnknownType;
import org.opendaylight.controller.yang.parser.builder.api.Builder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
+import org.opendaylight.controller.yang.parser.builder.api.DataSchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.SchemaNodeBuilder;
import org.opendaylight.controller.yang.parser.builder.api.TypeDefinitionBuilder;
import org.opendaylight.controller.yang.parser.builder.impl.ChoiceBuilder;
import org.slf4j.LoggerFactory;
public final class ParserListenerUtils {
- private static final Logger logger = LoggerFactory.getLogger(ParserListenerUtils.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ParserListenerUtils.class);
private ParserListenerUtils() {
}
} else if ("obsolete".equals(statusArgStr)) {
result = Status.OBSOLETE;
} else {
- logger.warn("Invalid 'status' statement: " + statusArgStr);
+ LOG.warn("Invalid 'status' statement: " + statusArgStr);
}
}
}
final List<String> path, final URI namespace, final Date revision, final String prefix) {
List<EnumTypeDefinition.EnumPair> enumConstants = new ArrayList<EnumTypeDefinition.EnumPair>();
- for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree enumSpecChild = ctx.getChild(j);
+ for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree enumSpecChild = ctx.getChild(i);
if (enumSpecChild instanceof Enum_specificationContext) {
int highestValue = -1;
- for (int k = 0; k < enumSpecChild.getChildCount(); k++) {
- ParseTree enumChild = enumSpecChild.getChild(k);
+ for (int j = 0; j < enumSpecChild.getChildCount(); j++) {
+ ParseTree enumChild = enumSpecChild.getChild(j);
if (enumChild instanceof Enum_stmtContext) {
EnumPair enumPair = createEnumPair((Enum_stmtContext) enumChild, highestValue, path, namespace,
revision, prefix);
private String description;
private String reference;
private Status status;
- private List<UnknownSchemaNode> extensionSchemaNodes = Collections.emptyList();
+ private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
private String name;
private Integer value;
@Override
public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return extensionSchemaNodes;
+ return unknownNodes;
}
@Override
int result = 1;
result = prime * result + ((qname == null) ? 0 : qname.hashCode());
result = prime * result + ((path == null) ? 0 : path.hashCode());
- result = prime * result + ((extensionSchemaNodes == null) ? 0 : extensionSchemaNodes.hashCode());
+ result = prime * result + ((unknownNodes == null) ? 0 : unknownNodes.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
} else if (!path.equals(other.path)) {
return false;
}
- if (extensionSchemaNodes == null) {
- if (other.extensionSchemaNodes != null) {
+ if (unknownNodes == null) {
+ if (other.unknownNodes != null) {
return false;
}
- } else if (!extensionSchemaNodes.equals(other.extensionSchemaNodes)) {
+ } else if (!unknownNodes.equals(other.unknownNodes)) {
return false;
}
if (name == null) {
*/
private static List<RangeConstraint> getRangeConstraints(final Type_body_stmtsContext ctx) {
List<RangeConstraint> rangeConstraints = Collections.emptyList();
- outer: for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree numRestrChild = ctx.getChild(j);
+ outer: for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree numRestrChild = ctx.getChild(i);
if (numRestrChild instanceof Numerical_restrictionsContext) {
- for (int k = 0; k < numRestrChild.getChildCount(); k++) {
- ParseTree rangeChild = numRestrChild.getChild(k);
+ for (int j = 0; j < numRestrChild.getChildCount(); j++) {
+ ParseTree rangeChild = numRestrChild.getChild(j);
if (rangeChild instanceof Range_stmtContext) {
rangeConstraints = parseRangeConstraints((Range_stmtContext) rangeChild);
break outer;
*/
private static List<LengthConstraint> getLengthConstraints(final Type_body_stmtsContext ctx) {
List<LengthConstraint> lengthConstraints = Collections.emptyList();
- outer: for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree stringRestrChild = ctx.getChild(j);
+ outer: for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree stringRestrChild = ctx.getChild(i);
if (stringRestrChild instanceof String_restrictionsContext) {
- for (int k = 0; k < stringRestrChild.getChildCount(); k++) {
- ParseTree lengthChild = stringRestrChild.getChild(k);
+ for (int j = 0; j < stringRestrChild.getChildCount(); j++) {
+ ParseTree lengthChild = stringRestrChild.getChild(j);
if (lengthChild instanceof Length_stmtContext) {
lengthConstraints = parseLengthConstraints((Length_stmtContext) lengthChild);
break outer;
private static List<PatternConstraint> getPatternConstraint(final Type_body_stmtsContext ctx) {
List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();
- for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree stringRestrChild = ctx.getChild(j);
+ for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree stringRestrChild = ctx.getChild(i);
if (stringRestrChild instanceof String_restrictionsContext) {
- for (int k = 0; k < stringRestrChild.getChildCount(); k++) {
- ParseTree lengthChild = stringRestrChild.getChild(k);
+ for (int j = 0; j < stringRestrChild.getChildCount(); j++) {
+ ParseTree lengthChild = stringRestrChild.getChild(j);
if (lengthChild instanceof Pattern_stmtContext) {
patterns.add(parsePatternConstraint((Pattern_stmtContext) lengthChild));
}
*
* @param ctx
* type body context to parse
+ * @param moduleName
+ * name of current module
* @return 'fraction-digits' value if present in given context, null
* otherwise
*/
- private static Integer getFractionDigits(Type_body_stmtsContext ctx) {
+ private static Integer getFractionDigits(Type_body_stmtsContext ctx, String moduleName) {
Integer result = null;
- for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree dec64specChild = ctx.getChild(j);
+ for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree dec64specChild = ctx.getChild(i);
if (dec64specChild instanceof Decimal64_specificationContext) {
- result = parseFractionDigits((Decimal64_specificationContext) dec64specChild);
+ result = parseFractionDigits((Decimal64_specificationContext) dec64specChild, moduleName);
}
}
return result;
*
* @param ctx
* decimal64 context
+ * @param moduleName
+ * name of current module
* @return fraction-digits value as Integer
*/
- private static Integer parseFractionDigits(Decimal64_specificationContext ctx) {
+ private static Integer parseFractionDigits(Decimal64_specificationContext ctx, String moduleName) {
Integer result = null;
- for (int k = 0; k < ctx.getChildCount(); k++) {
- ParseTree fdChild = ctx.getChild(k);
+ for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree fdChild = ctx.getChild(i);
if (fdChild instanceof Fraction_digits_stmtContext) {
String value = stringFromNode(fdChild);
try {
result = Integer.valueOf(value);
} catch (NumberFormatException e) {
- throw new YangParseException(ctx.getStart().getLine(), "Unable to parse fraction digits value '"
- + value + "'.", e);
+ throw new YangParseException(moduleName, ctx.getStart().getLine(),
+ "Unable to parse fraction digits value '" + value + "'.", e);
}
}
}
* list are determined by the user or the system. The argument is one of the
* strings "system" or "user". If not present, order defaults to "system".
*
- * @param childNode
+ * @param ctx
* Ordered_by_stmtContext
* @return true, if ordered-by contains value 'user', false otherwise
*/
- public static boolean parseUserOrdered(Ordered_by_stmtContext childNode) {
+ public static boolean parseUserOrdered(Ordered_by_stmtContext ctx) {
boolean result = false;
- for (int j = 0; j < childNode.getChildCount(); j++) {
- ParseTree orderArg = childNode.getChild(j);
+ for (int j = 0; j < ctx.getChildCount(); j++) {
+ ParseTree orderArg = ctx.getChild(j);
if (orderArg instanceof Ordered_by_argContext) {
String orderStr = stringFromNode(orderArg);
if ("system".equals(orderStr)) {
} else if ("user".equals(orderStr)) {
result = true;
} else {
- logger.warn("Invalid 'orderedby' statement.");
+ LOG.warn("Invalid 'ordered-by' statement.");
}
}
}
return result;
}
+ /**
+ * Get config statement from given context. If there is no config statement,
+ * return config value of parent
+ *
+ * @param ctx
+ * context to parse
+ * @param parent
+ * parent node
+ * @param moduleName
+ * name of current module
+ * @param line
+ * line in current module
+ * @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;
// parse configuration statement
- Boolean configuration = null;
+ Boolean config = null;
for (int i = 0; i < ctx.getChildCount(); i++) {
ParseTree child = ctx.getChild(i);
if (child instanceof Config_stmtContext) {
- configuration = parseConfig((Config_stmtContext) child);
+ config = parseConfig((Config_stmtContext) child);
break;
}
}
// If 'config' is not specified, the default is the same as the parent
// schema node's 'config' value
- if (configuration == null) {
- if (parent instanceof ConfigNode) {
- Boolean parentConfig = ((ConfigNode) parent).isConfiguration();
+ if (config == null) {
+ if (parent instanceof DataSchemaNodeBuilder) {
+ Boolean parentConfig = ((DataSchemaNodeBuilder) parent).isConfiguration();
// If the parent node is a rpc input or output, it can has
// config set to null
result = parentConfig == null ? true : parentConfig;
} else {
// Check first: if a node has 'config' set to 'false', no node
// underneath it can have 'config' set to 'true'
- if (parent instanceof ConfigNode) {
- Boolean parentConfig = ((ConfigNode) parent).isConfiguration();
- if (parentConfig == false && configuration == true) {
+ if (parent instanceof DataSchemaNodeBuilder && !(parent instanceof ChoiceCaseBuilder)) {
+ Boolean parentConfig = ((DataSchemaNodeBuilder) parent).isConfiguration();
+ if (!parentConfig && config) {
throw new YangParseException(moduleName, line,
"Can not set 'config' to 'true' if parent node has 'config' set to 'false'");
}
}
- result = configuration;
+ result = config;
}
return result;
/**
* Parse type body and create UnknownType definition.
*
+ * @param moduleName
+ * name of current module
* @param typedefQName
* qname of current type
* @param ctx
* @param parent
* @return UnknownType object with constraints from parsed type body
*/
- public static TypeDefinition<?> parseUnknownTypeWithBody(final QName typedefQName,
+ public static TypeDefinition<?> parseUnknownTypeWithBody(final String moduleName, final QName typedefQName,
final Type_body_stmtsContext ctx, final List<String> actualPath, final URI namespace, final Date revision,
final String prefix, final Builder parent) {
String typeName = typedefQName.getLocalName();
List<RangeConstraint> rangeStatements = getRangeConstraints(ctx);
List<LengthConstraint> lengthStatements = getLengthConstraints(ctx);
List<PatternConstraint> patternStatements = getPatternConstraint(ctx);
- Integer fractionDigits = getFractionDigits(ctx);
+ Integer fractionDigits = getFractionDigits(ctx, moduleName);
if (parent instanceof TypeDefinitionBuilder) {
TypeDefinitionBuilder typedef = (TypeDefinitionBuilder) parent;
final int line = typeBody.getStart().getLine();
TypeDefinition<?> baseType = null;
- Integer fractionDigits = getFractionDigits(typeBody);
+ Integer fractionDigits = getFractionDigits(typeBody, moduleName);
List<LengthConstraint> lengthStatements = getLengthConstraints(typeBody);
List<PatternConstraint> patternStatements = getPatternConstraint(typeBody);
List<RangeConstraint> rangeStatements = getRangeConstraints(typeBody);
} else if ("int64".equals(typeName)) {
intType = new Int64(baseTypePath);
}
- if(intType == null) {
- throw new YangParseException(moduleName, line, "Unknown yang type "+ typeName);
+ if (intType == null) {
+ throw new YangParseException(moduleName, line, "Unknown yang type " + typeName);
}
constraints.addRanges(intType.getRangeStatements());
baseType = intType;
} else if ("uint64".equals(typeName)) {
uintType = new Uint64(baseTypePath);
}
- if(uintType == null) {
- throw new YangParseException(moduleName, line, "Unknown yang type "+ typeName);
+ if (uintType == null) {
+ throw new YangParseException(moduleName, line, "Unknown yang type " + typeName);
}
constraints.addRanges(uintType.getRangeStatements());
baseType = uintType;
baseType = binaryType;
} else if ("instance-identifier".equals(typeName)) {
boolean requireInstance = isRequireInstance(typeBody);
- baseType = new InstanceIdentifier(baseTypePath, null, requireInstance);
+ return new InstanceIdentifier(baseTypePath, null, requireInstance);
}
if (parent instanceof TypeDefinitionBuilder && !(parent instanceof UnionTypeBuilder)) {
private static boolean isRequireInstance(Type_body_stmtsContext ctx) {
for (int i = 0; i < ctx.getChildCount(); i++) {
ParseTree child = ctx.getChild(i);
- if (child instanceof Require_instance_stmtContext) {
+ if (child instanceof Instance_identifier_specificationContext) {
for (int j = 0; j < child.getChildCount(); j++) {
- ParseTree reqArg = child.getChild(j);
- if (reqArg instanceof Require_instance_argContext) {
- return Boolean.valueOf(stringFromNode(reqArg));
+ ParseTree reqStmt = child.getChild(j);
+ if (reqStmt instanceof Require_instance_stmtContext) {
+ for (int k = 0; k < reqStmt.getChildCount(); k++) {
+ ParseTree reqArg = reqStmt.getChild(k);
+ if (reqArg instanceof Require_instance_argContext) {
+ return Boolean.valueOf(stringFromNode(reqArg));
+ }
+ }
}
}
}
}
- return false;
+ return true;
}
/**
private static Integer parseMinElements(Min_elements_stmtContext ctx) {
Integer result = null;
try {
- for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree minArg = ctx.getChild(j);
+ for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree minArg = ctx.getChild(i);
if (minArg instanceof Min_value_argContext) {
result = Integer.valueOf(stringFromNode(minArg));
}
private static Integer parseMaxElements(Max_elements_stmtContext ctx) {
Integer result = null;
try {
- for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree maxArg = ctx.getChild(j);
+ for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree maxArg = ctx.getChild(i);
if (maxArg instanceof Max_value_argContext) {
result = Integer.valueOf(stringFromNode(maxArg));
}
*/
public static boolean parseYinValue(Argument_stmtContext ctx) {
boolean yinValue = false;
- outer: for (int j = 0; j < ctx.getChildCount(); j++) {
- ParseTree yin = ctx.getChild(j);
+ outer: for (int i = 0; i < ctx.getChildCount(); i++) {
+ ParseTree yin = ctx.getChild(i);
if (yin instanceof Yin_element_stmtContext) {
- for (int k = 0; k < yin.getChildCount(); k++) {
- ParseTree yinArg = yin.getChild(k);
+ for (int j = 0; j < yin.getChildCount(); j++) {
+ ParseTree yinArg = yin.getChild(j);
if (yinArg instanceof Yin_element_argContext) {
String yinString = stringFromNode(yinArg);
if ("true".equals(yinString)) {
*
* @param refineCtx
* refine statement
- * @param line
- * current line in yang model
* @return RefineHolder object representing this refine statement
*/
public static RefineHolder parseRefine(Refine_stmtContext refineCtx) {
final String refineTarget = stringFromNode(refineCtx);
final RefineHolder refine = new RefineHolder(refineCtx.getStart().getLine(), refineTarget);
- for (int j = 0; j < refineCtx.getChildCount(); j++) {
- ParseTree refinePom = refineCtx.getChild(j);
+ for (int i = 0; i < refineCtx.getChildCount(); i++) {
+ ParseTree refinePom = refineCtx.getChild(i);
if (refinePom instanceof Refine_pomContext) {
- for (int k = 0; k < refinePom.getChildCount(); k++) {
- ParseTree refineStmt = refinePom.getChild(k);
+ for (int j = 0; j < refinePom.getChildCount(); j++) {
+ ParseTree refineStmt = refinePom.getChild(j);
parseRefineDefault(refine, refineStmt);
if (refineStmt instanceof Refine_leaf_stmtsContext) {
}
private static RefineHolder parseRefine(RefineHolder refine, Refine_container_stmtsContext refineStmt) {
- for (int m = 0; m < refineStmt.getChildCount(); m++) {
- ParseTree refineArg = refineStmt.getChild(m);
+ for (int i = 0; i < refineStmt.getChildCount(); i++) {
+ ParseTree refineArg = refineStmt.getChild(i);
if (refineArg instanceof Must_stmtContext) {
MustDefinition must = parseMust((Must_stmtContext) refineArg);
refine.setMust(must);
}
private static RefineHolder parseRefine(RefineHolder refine, Refine_list_stmtsContext refineStmt) {
- for (int m = 0; m < refineStmt.getChildCount(); m++) {
- ParseTree refineArg = refineStmt.getChild(m);
+ for (int i = 0; i < refineStmt.getChildCount(); i++) {
+ ParseTree refineArg = refineStmt.getChild(i);
if (refineArg instanceof Must_stmtContext) {
MustDefinition must = parseMust((Must_stmtContext) refineArg);
refine.setMust(must);
}
private static RefineHolder parseRefine(RefineHolder refine, Refine_leaf_list_stmtsContext refineStmt) {
- for (int m = 0; m < refineStmt.getChildCount(); m++) {
- ParseTree refineArg = refineStmt.getChild(m);
+ for (int i = 0; i < refineStmt.getChildCount(); i++) {
+ ParseTree refineArg = refineStmt.getChild(i);
if (refineArg instanceof Must_stmtContext) {
MustDefinition must = parseMust((Must_stmtContext) refineArg);
refine.setMust(must);
*/
public static Builder findRefineTargetBuilder(final GroupingBuilder grouping, final String refineNodeName) {
// search child nodes
- Builder result = grouping.getChildNode(refineNodeName);
+ Builder result = grouping.getDataChildByName(refineNodeName);
// search groupings
if (result == null) {
Set<GroupingBuilder> grps = grouping.getGroupingBuilders();
import org.opendaylight.controller.yang.model.api.MustDefinition;
import org.opendaylight.controller.yang.parser.builder.api.Builder;
-import org.opendaylight.controller.yang.parser.builder.api.ConfigNode;
import org.opendaylight.controller.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
-public final class RefineHolder implements Builder, ConfigNode {
+public final class RefineHolder implements Builder {
private Builder parent;
private final int line;
private final String name;
this.reference = reference;
}
- @Override
public Boolean isConfiguration() {
return config;
}
- @Override
public void setConfiguration(final Boolean config) {
this.config = config;
}
return name;
}
- public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
+ @Override
+ public List<UnknownSchemaNodeBuilder> getUnknownNodeBuilders() {
return addedUnknownNodes;
}
- public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
+ @Override
+ public void addUnknownNodeBuilder(UnknownSchemaNodeBuilder unknownNode) {
addedUnknownNodes.add(unknownNode);
}
String defaultStr = refine.getDefaultStr();
Boolean mandatory = refine.isMandatory();
MustDefinition must = refine.getMust();
- List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodes();
+ List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
if (defaultStr != null && !("".equals(defaultStr))) {
leaf.setDefaultStr(defaultStr);
}
if (unknownNodes != null) {
for (UnknownSchemaNodeBuilder unknown : unknownNodes) {
- leaf.addUnknownSchemaNode(unknown);
+ leaf.addUnknownNodeBuilder(unknown);
}
}
}
public static void refineContainer(ContainerSchemaNodeBuilder container, RefineHolder refine, int line) {
Boolean presence = refine.isPresence();
MustDefinition must = refine.getMust();
- List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodes();
+ List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
if (presence != null) {
container.setPresence(presence);
}
if (unknownNodes != null) {
for (UnknownSchemaNodeBuilder unknown : unknownNodes) {
- container.addUnknownSchemaNode(unknown);
+ container.addUnknownNodeBuilder(unknown);
}
}
}
MustDefinition must = refine.getMust();
Integer min = refine.getMinElements();
Integer max = refine.getMaxElements();
- List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodes();
+ List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
if (must != null) {
list.getConstraints().addMustDefinition(must);
}
if (unknownNodes != null) {
for (UnknownSchemaNodeBuilder unknown : unknownNodes) {
- list.addUnknownSchemaNode(unknown);
+ list.addUnknownNodeBuilder(unknown);
}
}
}
MustDefinition must = refine.getMust();
Integer min = refine.getMinElements();
Integer max = refine.getMaxElements();
- List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodes();
+ List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
if (must != null) {
leafList.getConstraints().addMustDefinition(must);
}
if (unknownNodes != null) {
for (UnknownSchemaNodeBuilder unknown : unknownNodes) {
- leafList.addUnknownSchemaNode(unknown);
+ leafList.addUnknownNodeBuilder(unknown);
}
}
}
public static void refineChoice(ChoiceBuilder choice, RefineHolder refine, int line) {
String defaultStr = refine.getDefaultStr();
Boolean mandatory = refine.isMandatory();
- List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodes();
+ List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
if (defaultStr != null) {
choice.setDefaultCase(defaultStr);
}
if (unknownNodes != null) {
for (UnknownSchemaNodeBuilder unknown : unknownNodes) {
- choice.addUnknownSchemaNode(unknown);
+ choice.addUnknownNodeBuilder(unknown);
}
}
}
public static void refineAnyxml(AnyXmlBuilder anyXml, RefineHolder refine, int line) {
Boolean mandatory = refine.isMandatory();
MustDefinition must = refine.getMust();
- List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodes();
+ List<UnknownSchemaNodeBuilder> unknownNodes = refine.getUnknownNodeBuilders();
if (mandatory != null) {
anyXml.getConstraints().setMandatory(mandatory);
}
if (unknownNodes != null) {
for (UnknownSchemaNodeBuilder unknown : unknownNodes) {
- anyXml.addUnknownSchemaNode(unknown);
+ anyXml.addUnknownNodeBuilder(unknown);
}
}
}
@Before
public void init() throws FileNotFoundException {
- testedModules = TestUtils.loadModules(getClass().getResource
- ("/types").getPath());
+ testedModules = TestUtils.loadModules(getClass().getResource("/types").getPath());
}
@Test
assertEquals(14, typedefs.size());
TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-version");
- assertTrue(type.getDescription().contains(
- "This value represents the version of the IP protocol."));
- assertTrue(type.getReference().contains(
- "RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"));
+ assertTrue(type.getDescription().contains("This value represents the version of the IP protocol."));
+ assertTrue(type.getReference().contains("RFC 2460: Internet Protocol, Version 6 (IPv6) Specification"));
EnumerationType enumType = (EnumerationType) type.getBaseType();
List<EnumPair> values = enumType.getValues();
EnumPair value0 = values.get(0);
assertEquals("unknown", value0.getName());
assertEquals(0, (int) value0.getValue());
- assertEquals(
- "An unknown or unspecified version of the Internet protocol.",
- value0.getDescription());
+ assertEquals("An unknown or unspecified version of the Internet protocol.", value0.getDescription());
EnumPair value1 = values.get(1);
assertEquals("ipv4", value1.getName());
assertEquals(1, (int) value1.getValue());
- assertEquals("The IPv4 protocol as defined in RFC 791.",
- value1.getDescription());
+ assertEquals("The IPv4 protocol as defined in RFC 791.", value1.getDescription());
EnumPair value2 = values.get(2);
assertEquals("ipv6", value2.getName());
assertEquals(2, (int) value2.getValue());
- assertEquals("The IPv6 protocol as defined in RFC 2460.",
- value2.getDescription());
+ assertEquals("The IPv6 protocol as defined in RFC 2460.", value2.getDescription());
}
@Test
public void testEnumeration() {
- Module tested = TestUtils
- .findModule(testedModules, "custom-types-test");
+ Module tested = TestUtils.findModule(testedModules, "custom-types-test");
Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "ip-version");
EnumPair value0 = values.get(0);
assertEquals("unknown", value0.getName());
assertEquals(0, (int) value0.getValue());
- assertEquals(
- "An unknown or unspecified version of the Internet protocol.",
- value0.getDescription());
+ assertEquals("An unknown or unspecified version of the Internet protocol.", value0.getDescription());
EnumPair value1 = values.get(1);
assertEquals("ipv4", value1.getName());
assertEquals(19, (int) value1.getValue());
- assertEquals("The IPv4 protocol as defined in RFC 791.",
- value1.getDescription());
+ assertEquals("The IPv4 protocol as defined in RFC 791.", value1.getDescription());
EnumPair value2 = values.get(2);
assertEquals("ipv6", value2.getName());
assertEquals(7, (int) value2.getValue());
- assertEquals("The IPv6 protocol as defined in RFC 2460.",
- value2.getDescription());
+ assertEquals("The IPv6 protocol as defined in RFC 2460.", value2.getDescription());
EnumPair value3 = values.get(3);
assertEquals("default", value3.getName());
ExtendedType ipv4 = (ExtendedType) unionTypes.get(0);
assertTrue(ipv4.getBaseType() instanceof StringTypeDefinition);
String expectedPattern = "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}"
- + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
- + "(%[\\p{N}\\p{L}]+)?";
- assertEquals(expectedPattern, ipv4.getPatterns().get(0)
- .getRegularExpression());
+ + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" + "(%[\\p{N}\\p{L}]+)?";
+ assertEquals(expectedPattern, ipv4.getPatterns().get(0).getRegularExpression());
TypeDefinition<?> ipv4Address = TestUtils.findTypedef(typedefs, "ipv4-address");
assertEquals(ipv4Address, ipv4);
assertTrue(ipv6.getBaseType() instanceof StringTypeDefinition);
List<PatternConstraint> ipv6Patterns = ipv6.getPatterns();
expectedPattern = "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}"
- + "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|"
- + "(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}"
- + "(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))"
- + "(%[\\p{N}\\p{L}]+)?";
- assertEquals(expectedPattern, ipv6Patterns.get(0)
- .getRegularExpression());
+ + "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|" + "(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}"
+ + "(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))" + "(%[\\p{N}\\p{L}]+)?";
+ assertEquals(expectedPattern, ipv6Patterns.get(0).getRegularExpression());
TypeDefinition<?> ipv6Address = TestUtils.findTypedef(typedefs, "ipv6-address");
assertEquals(ipv6Address, ipv6);
- expectedPattern = "(([^:]+:){6}(([^:]+:[^:]+)|(.*\\..*)))|"
- + "((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)" + "(%.+)?";
- assertEquals(expectedPattern, ipv6Patterns.get(1)
- .getRegularExpression());
+ expectedPattern = "(([^:]+:){6}(([^:]+:[^:]+)|(.*\\..*)))|" + "((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)"
+ + "(%.+)?";
+ assertEquals(expectedPattern, ipv6Patterns.get(1).getRegularExpression());
}
@Test
public void testDomainName() {
Module tested = TestUtils.findModule(testedModules, "ietf-inet-types");
Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
- ExtendedType type = (ExtendedType)TestUtils.findTypedef(typedefs, "domain-name");
+ ExtendedType type = (ExtendedType) TestUtils.findTypedef(typedefs, "domain-name");
assertTrue(type.getBaseType() instanceof StringTypeDefinition);
List<PatternConstraint> patterns = type.getPatterns();
assertEquals(1, patterns.size());
String expectedPattern = "((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*"
- + "([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)"
- + "|\\.";
+ + "([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.?)" + "|\\.";
assertEquals(expectedPattern, patterns.get(0).getRegularExpression());
List<LengthConstraint> lengths = type.getLengths();
@Test
public void testInstanceIdentifier1() {
- Module tested = TestUtils
- .findModule(testedModules, "custom-types-test");
- LeafSchemaNode leaf = (LeafSchemaNode) tested
- .getDataChildByName("inst-id-leaf1");
- ExtendedType leafType = (ExtendedType) leaf.getType();
- InstanceIdentifier leafTypeBase = (InstanceIdentifier) leafType
- .getBaseType();
- assertFalse(leafTypeBase.requireInstance());
+ Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+ LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName("inst-id-leaf1");
+ InstanceIdentifier leafType = (InstanceIdentifier) leaf.getType();
+ assertFalse(leafType.requireInstance());
}
@Test
public void testInstanceIdentifier2() {
- Module tested = TestUtils
- .findModule(testedModules, "custom-types-test");
- LeafSchemaNode leaf = (LeafSchemaNode) tested
- .getDataChildByName("inst-id-leaf2");
+ Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+ LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName("inst-id-leaf2");
InstanceIdentifier leafType = (InstanceIdentifier) leaf.getType();
assertTrue(leafType.requireInstance());
}
@Test
public void testIdentity() {
- Module tested = TestUtils
- .findModule(testedModules, "custom-types-test");
+ Module tested = TestUtils.findModule(testedModules, "custom-types-test");
Set<IdentitySchemaNode> identities = tested.getIdentities();
IdentitySchemaNode testedIdentity = null;
for (IdentitySchemaNode id : identities) {
if (id.getQName().getLocalName().equals("crypto-alg")) {
testedIdentity = id;
IdentitySchemaNode baseIdentity = id.getBaseIdentity();
- assertEquals("crypto-base", baseIdentity.getQName()
- .getLocalName());
+ assertEquals("crypto-base", baseIdentity.getQName().getLocalName());
assertNull(baseIdentity.getBaseIdentity());
}
}
@Test
public void testBitsType1() {
- Module tested = TestUtils
- .findModule(testedModules, "custom-types-test");
- LeafSchemaNode leaf = (LeafSchemaNode) tested
- .getDataChildByName("mybits");
+ Module tested = TestUtils.findModule(testedModules, "custom-types-test");
+ LeafSchemaNode leaf = (LeafSchemaNode) tested.getDataChildByName("mybits");
BitsType leafType = (BitsType) leaf.getType();
List<Bit> bits = leafType.getBits();
assertEquals(3, bits.size());
@Test
public void testBitsType2() {
- Module tested = TestUtils
- .findModule(testedModules, "custom-types-test");
+ Module tested = TestUtils.findModule(testedModules, "custom-types-test");
Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
- TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs,
- "access-operations-type");
+ TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "access-operations-type");
BitsType bitsType = (BitsType) testedType.getBaseType();
List<Bit> bits = bitsType.getBits();
public void testIanaTimezones() {
Module tested = TestUtils.findModule(testedModules, "iana-timezones");
Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
- TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs,
- "iana-timezone");
+ TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "iana-timezone");
String expectedDesc = "A timezone location as defined by the IANA timezone";
assertTrue(testedType.getDescription().contains(expectedDesc));
assertEquals(Status.CURRENT, testedType.getStatus());
QName testedTypeQName = testedType.getQName();
- assertEquals(URI.create("urn:ietf:params:xml:ns:yang:iana-timezones"),
- testedTypeQName.getNamespace());
- assertEquals(TestUtils.createDate("2012-07-09"),
- testedTypeQName.getRevision());
+ assertEquals(URI.create("urn:ietf:params:xml:ns:yang:iana-timezones"), testedTypeQName.getNamespace());
+ assertEquals(TestUtils.createDate("2012-07-09"), testedTypeQName.getRevision());
assertEquals("ianatz", testedTypeQName.getPrefix());
assertEquals("iana-timezone", testedTypeQName.getLocalName());
EnumPair enum168 = values.get(168);
assertEquals("America/Danmarkshavn", enum168.getName());
assertEquals(168, (int) enum168.getValue());
- assertEquals("east coast, north of Scoresbysund",
- enum168.getDescription());
+ assertEquals("east coast, north of Scoresbysund", enum168.getDescription());
EnumPair enum374 = values.get(374);
assertEquals("America/Indiana/Winamac", enum374.getName());
assertEquals(374, (int) enum374.getValue());
- assertEquals("Eastern Time - Indiana - Pulaski County",
- enum374.getDescription());
+ assertEquals("Eastern Time - Indiana - Pulaski County", enum374.getDescription());
}
@Test
public void testObjectId128() {
Module tested = TestUtils.findModule(testedModules, "ietf-yang-types");
Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
- ExtendedType testedType = (ExtendedType) TestUtils.findTypedef(
- typedefs, "object-identifier-128");
+ ExtendedType testedType = (ExtendedType) TestUtils.findTypedef(typedefs, "object-identifier-128");
List<PatternConstraint> patterns = testedType.getPatterns();
assertEquals(1, patterns.size());
assertEquals("\\d*(\\.\\d*){1,127}", pattern.getRegularExpression());
QName testedTypeQName = testedType.getQName();
- assertEquals(URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-types"),
- testedTypeQName.getNamespace());
- assertEquals(TestUtils.createDate("2010-09-24"),
- testedTypeQName.getRevision());
+ assertEquals(URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-types"), testedTypeQName.getNamespace());
+ assertEquals(TestUtils.createDate("2010-09-24"), testedTypeQName.getRevision());
assertEquals("yang", testedTypeQName.getPrefix());
assertEquals("object-identifier-128", testedTypeQName.getLocalName());
assertEquals(1, patterns.size());
pattern = patterns.get(0);
- assertEquals(
- "(([0-1](\\.[1-3]?[0-9]))|(2\\.(0|([1-9]\\d*))))(\\.(0|([1-9]\\d*)))*",
+ assertEquals("(([0-1](\\.[1-3]?[0-9]))|(2\\.(0|([1-9]\\d*))))(\\.(0|([1-9]\\d*)))*",
pattern.getRegularExpression());
QName testedTypeBaseQName = testedTypeBase.getQName();
- assertEquals(URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-types"),
- testedTypeBaseQName.getNamespace());
- assertEquals(TestUtils.createDate("2010-09-24"),
- testedTypeBaseQName.getRevision());
+ assertEquals(URI.create("urn:ietf:params:xml:ns:yang:ietf-yang-types"), testedTypeBaseQName.getNamespace());
+ assertEquals(TestUtils.createDate("2010-09-24"), testedTypeBaseQName.getRevision());
assertEquals("yang", testedTypeBaseQName.getPrefix());
assertEquals("object-identifier", testedTypeBaseQName.getLocalName());
}
@Test
public void testIdentityref() {
- Module tested = TestUtils
- .findModule(testedModules, "custom-types-test");
+ Module tested = TestUtils.findModule(testedModules, "custom-types-test");
Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
- TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs,
- "service-type-ref");
+ TypeDefinition<?> testedType = TestUtils.findTypedef(typedefs, "service-type-ref");
IdentityrefType baseType = (IdentityrefType) testedType.getBaseType();
QName identity = baseType.getIdentity();
- assertEquals(URI.create("urn:simple.container.demo"),
- identity.getNamespace());
+ assertEquals(URI.create("urn:simple.container.demo"), identity.getNamespace());
assertEquals(TestUtils.createDate("2012-04-16"), identity.getRevision());
assertEquals("iit", identity.getPrefix());
assertEquals("service-type", identity.getLocalName());