Refactored SchemaPath construction for int, uint, decimal64, string and union types.
Signed-off-by: Martin Vitez <mvitez@cisco.com>
identifier_stmt : IDENTIFIER string? stmtend;
-stmtend : (SEMICOLON identifier_stmt?) | (LEFT_BRACE identifier_stmt? RIGHT_BRACE);
+stmtend : (SEMICOLON) | (LEFT_BRACE identifier_stmt? RIGHT_BRACE);
deviate_replace_stmt : DEVIATE_KEYWORD string /* REPLACE_KEYWORD */ (SEMICOLON | (LEFT_BRACE (identifier_stmt |type_stmt | units_stmt | default_stmt | config_stmt | mandatory_stmt | min_elements_stmt | max_elements_stmt )* RIGHT_BRACE));
deviate_delete_stmt : DEVIATE_KEYWORD string /* DELETE_KEYWORD */ (SEMICOLON | (LEFT_BRACE (identifier_stmt |units_stmt | must_stmt | unique_stmt | default_stmt )* RIGHT_BRACE));
deviate_add_stmt : DEVIATE_KEYWORD string /*ADD_KEYWORD*/ (SEMICOLON | (LEFT_BRACE (identifier_stmt |units_stmt | must_stmt | unique_stmt | default_stmt | config_stmt | mandatory_stmt | min_elements_stmt | max_elements_stmt )* RIGHT_BRACE));
path_stmt : PATH_KEYWORD string stmtend;
leafref_specification : path_stmt;
enum_stmt : ENUM_KEYWORD string (SEMICOLON | (LEFT_BRACE (identifier_stmt |value_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
-enum_specification : enum_stmt (identifier_stmt | enum_stmt )+;
+enum_specification : enum_stmt (identifier_stmt | enum_stmt )*;
default_stmt : DEFAULT_KEYWORD string stmtend;
pattern_stmt : PATTERN_KEYWORD string (SEMICOLON | (LEFT_BRACE (identifier_stmt |error_message_stmt | error_app_tag_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
length_stmt : LENGTH_KEYWORD string (SEMICOLON | (LEFT_BRACE (identifier_stmt |error_message_stmt | error_app_tag_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
*/
package org.opendaylight.controller.yang.model.parser.builder.impl;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
private final IdentitySchemaNodeImpl instance;
private IdentitySchemaNodeBuilder baseIdentity;
private String baseIdentityName;
+ private final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
IdentitySchemaNodeBuilder(final QName qname) {
this.qname = qname;
final IdentitySchemaNode base = baseIdentity.build();
instance.setBaseIdentity(base);
}
+
+ // UNKNOWN NODES
+ final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
+ for (UnknownSchemaNodeBuilder b : addedUnknownNodes) {
+ unknownNodes.add(b.build());
+ }
+ instance.setUnknownSchemaNodes(unknownNodes);
+
return instance;
}
}
}
+ public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
+ return addedUnknownNodes;
+ }
+
@Override
- public void addUnknownSchemaNode(final UnknownSchemaNodeBuilder unknownNode) {
- throw new IllegalStateException(
- "Can not add schema node to identity statement");
+ public void addUnknownSchemaNode(UnknownSchemaNodeBuilder unknownNode) {
+ addedUnknownNodes.add(unknownNode);
}
public String getBaseIdentityName() {
private String reference;
private Status status = Status.CURRENT;
private SchemaPath path;
+ private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
private IdentitySchemaNodeImpl(final QName qname) {
this.qname = qname;
@Override
public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return Collections.emptyList();
+ return unknownNodes;
+ }
+
+ private void setUnknownSchemaNodes(
+ List<UnknownSchemaNode> unknownSchemaNodes) {
+ if (unknownSchemaNodes != null) {
+ this.unknownNodes = unknownSchemaNodes;
+ }
}
@Override
List<String> pathToCase = new ArrayList<String>(parentPath);
ChoiceCaseBuilder builder = new ChoiceCaseBuilder(caseName);
- final ChoiceBuilder parent = (ChoiceBuilder) moduleNodes
+ final ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
.get(pathToCase);
if (parent != null) {
if (parent instanceof AugmentationSchemaBuilder) {
}
pathToCase.add(caseName.getLocalName());
- addedChilds.put(pathToCase, builder);
moduleNodes.put(pathToCase, builder);
return builder;
}
public void addIdentityrefType(String baseString, List<String> parentPath) {
+ List<String> pathToIdentityref = new ArrayList<String>(parentPath);
TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes
- .get(parentPath);
+ .get(pathToIdentityref);
IdentityrefTypeBuilder identityref = new IdentityrefTypeBuilder(baseString);
parent.setType(identityref);
- dirtyNodes.put(parentPath, parent);
+ dirtyNodes.put(pathToIdentityref, parent);
}
public DeviationBuilder addDeviation(String targetPath,
return builder;
}
- public IdentitySchemaNodeBuilder addIdentity(QName qname) {
+ public IdentitySchemaNodeBuilder addIdentity(QName qname, List<String> parentPath) {
+ List<String> pathToIdentity = new ArrayList<String>(parentPath);
IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(qname);
+ pathToIdentity.add(qname.getLocalName());
+ moduleNodes.put(pathToIdentity, builder);
addedIdentities.add(builder);
return builder;
}
final QName currentQName = currentParent.getQName();
final QName lastAugmentPathElement = path.get(path.size() - 1);
-
if (currentQName.getLocalName().equals(
lastAugmentPathElement.getLocalName())) {
fillAugmentTarget(augmentBuilder,
}
}
}
-
}
/**
if(baseString.contains(":")) {
String[] splittedBase = baseString.split(":");
if(splittedBase.length > 2) {
- throw new YangParseException("Failed to parse identity base: "+ baseString);
+ throw new YangParseException("Failed to parse identityref base: "+ baseString);
}
String prefix = splittedBase[0];
String name = splittedBase[1];
if (prefix.equals(module.getPrefix())) {
dependentModule = module;
} else {
- final ModuleImport dependentModuleImport = getModuleImport(module,
+ final ModuleImport dependentModuleImport = ParserUtils.getModuleImport(module,
prefix);
if (dependentModuleImport == null) {
throw new YangParseException("No import found with prefix '"
return dependentModule;
}
- /**
- * Get module import referenced by given prefix.
- *
- * @param builder
- * module to search
- * @param prefix
- * prefix associated with import
- * @return ModuleImport based on given prefix
- */
- private ModuleImport getModuleImport(final ModuleBuilder builder,
- final String prefix) {
- ModuleImport moduleImport = null;
- for (ModuleImport mi : builder.getModuleImports()) {
- if (mi.getPrefix().equals(prefix)) {
- moduleImport = mi;
- break;
- }
- }
- return moduleImport;
- }
private static class SchemaContextImpl implements SchemaContext {
private final Set<Module> modules;
if (YangTypesConverter.isBaseYangType(typeName)) {
if (typeBody == null) {
// if there are no constraints, just grab default base yang type
- type = YangTypesConverter.javaTypeForBaseYangType(typeName);
+ type = YangTypesConverter.javaTypeForBaseYangType(actualPath, namespace, revision, typeName);
moduleBuilder.setType(type, actualPath);
} else {
if ("union".equals(typeName)) {
final QName identityQName = new QName(namespace, revision,
yangModelPrefix, identityName);
IdentitySchemaNodeBuilder builder = moduleBuilder
- .addIdentity(identityQName);
+ .addIdentity(identityQName, actualPath);
updatePath(identityName);
builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ModuleImport;
import org.opendaylight.controller.yang.model.api.MustDefinition;
import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.TypeDefinition;
import org.opendaylight.controller.yang.model.parser.builder.impl.LeafListSchemaNodeBuilder;
import org.opendaylight.controller.yang.model.parser.builder.impl.LeafSchemaNodeBuilder;
import org.opendaylight.controller.yang.model.parser.builder.impl.ListSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaNodeBuilder;
public final class ParserUtils {
private ParserUtils() {
}
+ /**
+ * Get module import referenced by given prefix.
+ *
+ * @param builder
+ * module to search
+ * @param prefix
+ * prefix associated with import
+ * @return ModuleImport based on given prefix
+ */
+ public static ModuleImport getModuleImport(final ModuleBuilder builder,
+ final String prefix) {
+ ModuleImport moduleImport = null;
+ for (ModuleImport mi : builder.getModuleImports()) {
+ if (mi.getPrefix().equals(prefix)) {
+ moduleImport = mi;
+ break;
+ }
+ }
+ return moduleImport;
+ }
+
+ /**
+ * Parse uses path.
+ * @param usesPath as String
+ * @return SchemaPath from given String
+ */
public static SchemaPath parseUsesPath(final String usesPath) {
final boolean absolute = usesPath.startsWith("/");
final String[] splittedPath = usesPath.split("/");
import org.opendaylight.controller.yang.model.util.BaseConstraints;
import org.opendaylight.controller.yang.model.util.BinaryType;
import org.opendaylight.controller.yang.model.util.BitsType;
+import org.opendaylight.controller.yang.model.util.Decimal64;
import org.opendaylight.controller.yang.model.util.EnumerationType;
import org.opendaylight.controller.yang.model.util.InstanceIdentifier;
+import org.opendaylight.controller.yang.model.util.Int16;
+import org.opendaylight.controller.yang.model.util.Int32;
+import org.opendaylight.controller.yang.model.util.Int64;
+import org.opendaylight.controller.yang.model.util.Int8;
import org.opendaylight.controller.yang.model.util.Leafref;
import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
import org.opendaylight.controller.yang.model.util.StringType;
+import org.opendaylight.controller.yang.model.util.Uint16;
+import org.opendaylight.controller.yang.model.util.Uint32;
+import org.opendaylight.controller.yang.model.util.Uint64;
+import org.opendaylight.controller.yang.model.util.Uint8;
import org.opendaylight.controller.yang.model.util.UnknownType;
-import org.opendaylight.controller.yang.model.util.YangTypesConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
typeBody, actualPath, namespace, revision, prefix);
if ("decimal64".equals(typeName)) {
- type = YangTypesConverter.javaTypeForBaseYangDecimal64Type(
- rangeStatements, fractionDigits);
+ type = new Decimal64(actualPath, namespace, revision, fractionDigits);
} else if (typeName.startsWith("int")) {
- type = YangTypesConverter.javaTypeForBaseYangSignedIntegerType(
- typeName, rangeStatements);
+ if (typeName.equals("int8")) {
+ type = new Int8(actualPath, namespace, revision, rangeStatements, null, null);
+ } else if (typeName.equals("int16")) {
+ type = new Int16(actualPath, namespace, revision, rangeStatements, null, null);
+ } else if (typeName.equals("int32")) {
+ type = new Int32(actualPath, namespace, revision, rangeStatements, null, null);
+ } else if (typeName.equals("int64")) {
+ type = new Int64(actualPath, namespace, revision, rangeStatements, null, null);
+ }
} else if (typeName.startsWith("uint")) {
- type = YangTypesConverter.javaTypeForBaseYangUnsignedIntegerType(
- typeName, rangeStatements);
+ if (typeName.equals("uint8")) {
+ type = new Uint8(actualPath, namespace, revision, rangeStatements, null, null);
+ } else if (typeName.equals("uint16")) {
+ type = new Uint16(actualPath, namespace, revision, rangeStatements, null, null);
+ } else if (typeName.equals("uint32")) {
+ type = new Uint32(actualPath, namespace, revision, rangeStatements, null, null);
+ } else if (typeName.equals("uint64")) {
+ type = new Uint64(actualPath, namespace, revision, rangeStatements, null, null);
+ }
} else if ("enumeration".equals(typeName)) {
type = new EnumerationType(actualPath, namespace, revision,
enumConstants);
} else if ("string".equals(typeName)) {
- type = new StringType(lengthStatements, patternStatements);
+ type = new StringType(actualPath, namespace, revision, lengthStatements, patternStatements);
} else if ("bits".equals(typeName)) {
type = new BitsType(getBits(typeBody, actualPath, namespace,
revision, prefix));
LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry
.getDataChildByName("ifIndex");
- assertEquals(new Uint32(), ifIndex.getType());
+ assertTrue(ifIndex.getType() instanceof Uint32);
LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry
.getDataChildByName("ifMtu");
- assertEquals(new Int32(), ifMtu.getType());
+ assertTrue(ifMtu.getType() instanceof Int32);
}
@Test
assertNotNull(output.getDataChildByName("data"));
}
- @Test
- public void test() {
- Module testModule = TestUtils.findModule(modules, "types4");
-
- boolean flag = false;
- }
-
}
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
* interface which represents SIGNED Integer values defined in Yang language. <br>
* The integer built-in types in Yang are int8, int16, int32, int64. They
* represent signed integers of different sizes:
- *
+ *
* <ul>
* <li>int8 - represents integer values between -128 and 127, inclusively.</li>
* <li>int16 - represents integer values between -32768 and 32767, inclusively.</li>
* <li>int64 - represents integer values between -9223372036854775808 and
* 9223372036854775807, inclusively.</li>
* </ul>
- *
+ *
*/
public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
* @param maxRange
* @param units
*/
- public AbstractSignedInteger(final QName name, final String description,
- final Number minRange, final Number maxRange, final String units) {
+ public AbstractSignedInteger(final List<String> actualPath,
+ final URI namespace, final Date revision, final QName name,
+ final String description, final Number minRange,
+ final Number maxRange, final String units) {
this.name = name;
this.description = description;
- this.path = BaseTypes.schemaPath(name);
+ this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
this.units = units;
this.rangeStatements = new ArrayList<RangeConstraint>();
final String rangeDescription = "Integer values between " + minRange
+ " and " + maxRange + ", inclusively.";
this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
- maxRange, rangeDescription, "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
+ maxRange, rangeDescription,
+ "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
}
/**
* @param rangeStatements
* @param units
*/
- public AbstractSignedInteger(final QName name, final String description,
+ public AbstractSignedInteger(final List<String> actualPath,
+ final URI namespace, final Date revision, final QName name,
+ final String description,
final List<RangeConstraint> rangeStatements, final String units) {
this.name = name;
this.description = description;
- this.path = BaseTypes.schemaPath(name);
+ this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
this.units = units;
this.rangeStatements = rangeStatements;
}
/**
- *
+ *
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
/**
* The Abstract Integer class defines implementation of IntegerTypeDefinition
* interface which represents UNSIGNED Integer values defined in Yang language. <br>
- * The integer built-in types in Yang are uint8, uint16, uint32, and uint64. They
- * represent unsigned integers of different sizes:
- *
+ * The integer built-in types in Yang are uint8, uint16, uint32, and uint64.
+ * They represent unsigned integers of different sizes:
+ *
* <ul>
* <li>uint8 - represents integer values between 0 and 255, inclusively.</li>
* <li>uint16 - represents integer values between 0 and 65535, inclusively.</li>
- * <li>uint32 - represents integer values between 0 and 4294967295,
- inclusively.</li>
+ * <li>uint32 - represents integer values between 0 and 4294967295, inclusively.
+ * </li>
* <li>uint64 - represents integer values between 0 and 18446744073709551615,
- inclusively.</li>
+ * inclusively.</li>
* </ul>
*
*/
private final String units;
private final List<RangeConstraint> rangeStatements;
-
+
/**
* @param name
* @param description
* @param maxRange
* @param units
*/
- public AbstractUnsignedInteger(final QName name, final String description,
- final Number minRange, final Number maxRange, final String units) {
+ public AbstractUnsignedInteger(final List<String> actualPath,
+ final URI namespace, final Date revision, final QName name,
+ final String description, final Number minRange,
+ final Number maxRange, final String units) {
this.name = name;
this.description = description;
- this.path = BaseTypes.schemaPath(name);
+ this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
this.units = units;
this.rangeStatements = new ArrayList<RangeConstraint>();
final String rangeDescription = "Integer values between " + minRange
+ " and " + maxRange + ", inclusively.";
this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
- maxRange, rangeDescription, "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
+ maxRange, rangeDescription,
+ "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
}
/**
* @param rangeStatements
* @param units
*/
- public AbstractUnsignedInteger(final QName name, final String description,
+ public AbstractUnsignedInteger(final List<String> actualPath,
+ final URI namespace, final Date revision, final QName name,
+ final String description,
final List<RangeConstraint> rangeStatements, final String units) {
this.name = name;
this.description = description;
- this.path = BaseTypes.schemaPath(name);
+ this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
this.units = units;
this.rangeStatements = rangeStatements;
}
-
+
@Override
public String getUnits() {
return units;
package org.opendaylight.controller.yang.model.util;
import java.math.BigDecimal;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
/**
* The <code>default</code> implementation of Decimal Type Definition interface.
- *
- *
+ *
+ *
* @see DecimalTypeDefinition
*/
public class Decimal64 implements DecimalTypeDefinition {
* inclusively as defined interface {@link DecimalTypeDefinition} <br>
* If the fraction digits are not defined inner the definition boundaries
* the constructor will throw {@link IllegalArgumentException}
- *
+ *
* @param fractionDigits
* integer between 1 and 18 inclusively
- *
+ *
* @see DecimalTypeDefinition
* @exception IllegalArgumentException
*/
- public Decimal64(final Integer fractionDigits) {
+ public Decimal64(final List<String> actualPath, final URI namespace,
+ final Date revision, final Integer fractionDigits) {
super();
if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
throw new IllegalArgumentException(
}
this.fractionDigits = fractionDigits;
rangeStatements = defaultRangeStatements();
- this.path = BaseTypes.schemaPath(name);
+ this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
}
/**
* Decimal64 Type Constructor. <br>
- *
+ *
* If parameter <code>Range Statements</code> is <code>null</code> or
* defined as <code>empty List</code> the constructor automatically assigns
* the boundaries as min and max value defined for Decimal64 in <a
* inclusively as defined interface {@link DecimalTypeDefinition} <br>
* If the fraction digits are not defined inner the definition boundaries
* the constructor will throw {@link IllegalArgumentException}
- *
+ *
* @param rangeStatements
* Range Constraint Statements
* @param fractionDigits
* integer between 1 and 18 inclusively
* @exception IllegalArgumentException
*/
- public Decimal64(final List<RangeConstraint> rangeStatements,
+ public Decimal64(final List<String> actualPath, final URI namespace,
+ final Date revision, final List<RangeConstraint> rangeStatements,
Integer fractionDigits) {
super();
if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
this.rangeStatements = Collections.unmodifiableList(rangeStatements);
}
this.fractionDigits = fractionDigits;
- this.path = BaseTypes.schemaPath(name);
+ this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
}
/**
* inclusively as defined interface {@link DecimalTypeDefinition} <br>
* If the fraction digits are not defined inner the definition boundaries
* the constructor will throw {@link IllegalArgumentException}
- *
+ *
* @param units
* units associated with the type
* @param defaultValue
* Range Constraint Statements
* @param fractionDigits
* integer between 1 and 18 inclusively
- *
+ *
* @exception IllegalArgumentException
*/
- public Decimal64(final String units, final BigDecimal defaultValue,
+ public Decimal64(final List<String> actualPath, final URI namespace,
+ final Date revision, final String units, final BigDecimal defaultValue,
final List<RangeConstraint> rangeStatements,
final Integer fractionDigits) {
super();
if (rangeStatements == null || rangeStatements.isEmpty()) {
this.rangeStatements = defaultRangeStatements();
-
+
} else {
this.rangeStatements = Collections.unmodifiableList(rangeStatements);
}
/**
* Returns unmodifiable List with default definition of Range Statements.
- *
+ *
* @return unmodifiable List with default definition of Range Statements.
*/
private List<RangeConstraint> defaultRangeStatements() {
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
* Implementation of Yang int16 built-in type. <br>
* int16 represents integer values between -32768 and 32767, inclusively. The
* Java counterpart of Yang int16 built-in type is {@link Short}.
- *
+ *
* @see AbstractSignedInteger
*/
public class Int16 extends AbstractSignedInteger {
private static final QName name = BaseTypes.constructQName("int16");
private Short defaultValue = null;
- private static final String description =
+ private static final String description =
"int16 represents integer values between -32768 and 32767, inclusively.";
- public Int16() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Int16(final List<String> actualPath, final URI namespace,
+ final Date revision) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
}
- public Int16(final List<RangeConstraint> rangeStatements,
+ public Int16(final List<String> actualPath, final URI namespace,
+ final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final Short defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
* int32 represents integer values between -2147483648 and 2147483647,
* inclusively. The Java counterpart of Yang int32 built-in type is
* {@link Integer}.
- *
+ *
* @see AbstractSignedInteger
- *
+ *
*/
public class Int32 extends AbstractSignedInteger {
private static final QName name = BaseTypes.constructQName("int32");
private Integer defaultValue = null;
- private static final String description =
+ private static final String description =
"int32 represents integer values between -2147483648 and 2147483647, inclusively.";
- public Int32() {
- super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+ public Int32(final List<String> actualPath, final URI namespace,
+ final Date revision) {
+ super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
}
- public Int32(final Integer defaultValue) {
- super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+ public Int32(final List<String> actualPath, final URI namespace,
+ final Date revision, final Integer defaultValue) {
+ super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
this.defaultValue = defaultValue;
}
- public Int32(final List<RangeConstraint> rangeStatements,
+ public Int32(final List<String> actualPath, final URI namespace,
+ final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final Integer defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
/*
* (non-Javadoc)
- *
+ *
* @see
* org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
* ()
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
/**
* Implementation of Yang int64 built-in type. <br>
- * int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.
+ * int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.
* The Java counterpart of Yang int64 built-in type is
* {@link Long}.
*
private static final QName name = BaseTypes.constructQName("int64");
private Long defaultValue = null;
- private static final String description =
+ private static final String description =
"int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";
- public Int64() {
- super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+ public Int64(final List<String> actualPath, final URI namespace,
+ final Date revision) {
+ super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
}
- public Int64(final Long defaultValue) {
- super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
+ public Int64(final List<String> actualPath, final URI namespace,
+ final Date revision, final Long defaultValue) {
+ super(actualPath, namespace, revision, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
this.defaultValue = defaultValue;
}
- public Int64(final List<RangeConstraint> rangeStatements,
+ public Int64(final List<String> actualPath, final URI namespace,
+ final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final Long defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
*/
@Override
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
/**
* Implementation of Yang int8 built-in type.
* <br>
- * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of
+ * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of
* Yang int8 built-in type is {@link Byte}.
- *
+ *
* @see AbstractSignedInteger
*/
public class Int8 extends AbstractSignedInteger {
private static final QName name = BaseTypes.constructQName("int8");
private Byte defaultValue = null;
- private static final String description =
+ private static final String description =
"represents integer values between -128 and 127, inclusively.";
-
- public Int8() {
- super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
+
+ public Int8(final List<String> actualPath, final URI namespace,
+ final Date revision) {
+ super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
}
- public Int8(final Byte defaultValue) {
- super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
+ public Int8(final List<String> actualPath, final URI namespace,
+ final Date revision, final Byte defaultValue) {
+ super(actualPath, namespace, revision, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
this.defaultValue = defaultValue;
}
- public Int8(final List<RangeConstraint> rangeStatements,
+ public Int8(final List<String> actualPath, final URI namespace,
+ final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final Byte defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
*/
@Override
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
/**
* Default Constructor.
*/
- public StringType() {
+ public StringType(final List<String> actualPath,
+ final URI namespace, final Date revision) {
super();
- path = BaseTypes.schemaPath(name);
+ path = BaseTypes.schemaPath(actualPath, namespace, revision);
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
lengthStatements = Collections.unmodifiableList(constraints);
* @param lengthStatements
* @param patterns
*/
- public StringType(final List<LengthConstraint> lengthStatements,
+ public StringType(final List<String> actualPath,
+ final URI namespace, final Date revision, final List<LengthConstraint> lengthStatements,
final List<PatternConstraint> patterns) {
super();
- path = BaseTypes.schemaPath(name);
+ path = BaseTypes.schemaPath(actualPath, namespace, revision);
if(lengthStatements == null || lengthStatements.size() == 0) {
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
* @param patterns
* @param units
*/
- public StringType(final String defaultValue,
+ public StringType(final List<String> actualPath,
+ final URI namespace, final Date revision, final String defaultValue,
final List<LengthConstraint> lengthStatements,
final List<PatternConstraint> patterns, final String units) {
super();
- path = BaseTypes.schemaPath(name);
+ path = BaseTypes.schemaPath(actualPath, namespace, revision);
this.defaultValue = defaultValue;
if(lengthStatements == null || lengthStatements.size() == 0) {
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
* Implementation of Yang uint32 built-in type. <br>
* uint16 represents integer values between 0 and 65535, inclusively. The Java
* counterpart of Yang uint32 built-in type is {@link Integer}.
- *
+ *
*/
public class Uint16 extends AbstractUnsignedInteger {
private Integer defaultValue = null;
private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
- public Uint16() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint16(final List<String> actualPath,
+ final URI namespace, final Date revision) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
}
- public Uint16(final Integer defaultValue) {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint16(final List<String> actualPath,
+ final URI namespace, final Date revision, final Integer defaultValue) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.defaultValue = defaultValue;
}
- public Uint16(final List<RangeConstraint> rangeStatements,
+ public Uint16(final List<String> actualPath,
+ final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final Integer defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
/*
* (non-Javadoc)
- *
+ *
* @see
* org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
* ()
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
* Implementation of Yang uint32 built-in type. <br>
* uint32 represents integer values between 0 and 4294967295, inclusively. The
* Java counterpart of Yang uint32 built-in type is {@link Long}.
- *
+ *
*/
public class Uint32 extends AbstractUnsignedInteger {
private Long defaultValue = null;
private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively.";
- public Uint32() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint32(final List<String> actualPath,
+ final URI namespace, final Date revision) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
}
- public Uint32(final Long defaultValue) {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint32(final List<String> actualPath,
+ final URI namespace, final Date revision, final Long defaultValue) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.defaultValue = defaultValue;
}
- public Uint32(final List<RangeConstraint> rangeStatements,
+ public Uint32(final List<String> actualPath,
+ final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final Long defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
/*
* (non-Javadoc)
- *
+ *
* @see
* org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
/*
* (non-Javadoc)
- *
+ *
* @see
* org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
* ()
package org.opendaylight.controller.yang.model.util;
import java.math.BigInteger;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
private static final String description =
"uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
- public Uint64() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint64(final List<String> actualPath,
+ final URI namespace, final Date revision) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
}
- public Uint64(final BigInteger defaultValue) {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint64(final List<String> actualPath,
+ final URI namespace, final Date revision, final BigInteger defaultValue) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.defaultValue = defaultValue;
}
- public Uint64(final List<RangeConstraint> rangeStatements,
+ public Uint64(final List<String> actualPath,
+ final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final BigInteger defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
*/
package org.opendaylight.controller.yang.model.util;
+import java.net.URI;
+import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
/**
* Implementation of Yang uint8 built-in type.
* <br>
- * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of
+ * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of
* Yang uint8 built-in type is {@link Short}.
- *
+ *
* @see AbstractUnsignedInteger
*/
public class Uint8 extends AbstractUnsignedInteger {
private static final QName name = BaseTypes.constructQName("uint8");
private Short defaultValue = null;
- private static final String description =
+ private static final String description =
"uint8 represents integer values between 0 and 255, inclusively.";
- public Uint8() {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint8(final List<String> actualPath,
+ final URI namespace, final Date revision) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
}
- public Uint8(final Short defaultValue) {
- super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ public Uint8(final List<String> actualPath,
+ final URI namespace, final Date revision, final Short defaultValue) {
+ super(actualPath, namespace, revision, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.defaultValue = defaultValue;
}
- public Uint8(final List<RangeConstraint> rangeStatements,
+ public Uint8(final List<String> actualPath,
+ final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
final String units, final Short defaultValue) {
- super(name, description, rangeStatements, units);
+ super(actualPath, namespace, revision, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
*/
@Override
*/\r
package org.opendaylight.controller.yang.model.util;\r
\r
+import java.net.URI;\r
+import java.util.Date;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
import java.util.List;\r
import org.opendaylight.controller.yang.model.api.type.BinaryTypeDefinition;\r
import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;\r
import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.type.DecimalTypeDefinition;\r
import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;\r
import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;\r
-import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;\r
\r
public class YangTypesConverter {\r
\r
private static final TypeDefinition<BitsTypeDefinition> BITS = new BitsType();\r
private static final TypeDefinition<BooleanTypeDefinition> BOOLEAN_TYPE = new BooleanType();\r
private static final TypeDefinition<EmptyTypeDefinition> EMPTY_TYPE = new EmptyType();\r
- private static final TypeDefinition<InstanceIdentifierTypeDefinition> INST_ID_TYPE = new InstanceIdentifier(null, true);\r
- private static final TypeDefinition<IntegerTypeDefinition> INT8_TYPE = new Int8();\r
- private static final TypeDefinition<IntegerTypeDefinition> INT16_TYPE = new Int16();\r
- private static final TypeDefinition<IntegerTypeDefinition> INT32_TYPE = new Int32();\r
- private static final TypeDefinition<IntegerTypeDefinition> INT64_TYPE = new Int64();\r
- private static final TypeDefinition<StringTypeDefinition> STRING_TYPE = new StringType();\r
- private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT8_TYPE = new Uint8();\r
- private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT16_TYPE = new Uint16();\r
- private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT32_TYPE = new Uint32();\r
- private static final TypeDefinition<UnsignedIntegerTypeDefinition> UINT64_TYPE = new Uint64();\r
+ private static final TypeDefinition<InstanceIdentifierTypeDefinition> INST_ID_TYPE = new InstanceIdentifier(\r
+ null, true);\r
\r
static {\r
baseYangTypeMap.put("binary", BINARY);\r
baseYangTypeMap.put("boolean", BOOLEAN_TYPE);\r
baseYangTypeMap.put("empty", EMPTY_TYPE);\r
baseYangTypeMap.put("instance-identifier", INST_ID_TYPE);\r
- baseYangTypeMap.put("int8", INT8_TYPE);\r
- baseYangTypeMap.put("int16", INT16_TYPE);\r
- baseYangTypeMap.put("int32", INT32_TYPE);\r
- baseYangTypeMap.put("int64", INT64_TYPE);\r
- baseYangTypeMap.put("string", STRING_TYPE);\r
- baseYangTypeMap.put("uint8", UINT8_TYPE);\r
- baseYangTypeMap.put("uint16", UINT16_TYPE);\r
- baseYangTypeMap.put("uint32", UINT32_TYPE);\r
- baseYangTypeMap.put("uint64", UINT64_TYPE);\r
\r
baseYangTypes.add("binary");\r
baseYangTypes.add("bits");\r
return type;\r
}\r
\r
- public static TypeDefinition<?> javaTypeForBaseYangType(String typeName) {\r
- TypeDefinition<?> type = baseYangTypeMap.get(typeName);\r
- return type;\r
- }\r
+ public static TypeDefinition<?> javaTypeForBaseYangType(\r
+ List<String> actualPath, URI namespace, Date revision,\r
+ String typeName) {\r
\r
- public static TypeDefinition<IntegerTypeDefinition> javaTypeForBaseYangSignedIntegerType(\r
- String typeName, List<RangeConstraint> ranges) {\r
- if (typeName.equals("int8")) {\r
- return new Int8(ranges, null, null);\r
- } else if (typeName.equals("int16")) {\r
- return new Int16(ranges, null, null);\r
- } else if (typeName.equals("int32")) {\r
- return new Int32(ranges, null, null);\r
- } else if (typeName.equals("int64")) {\r
- return new Int64(ranges, null, null);\r
+ if (typeName.startsWith("int")) {\r
+ if (typeName.equals("int8")) {\r
+ return new Int8(actualPath, namespace, revision);\r
+ } else if (typeName.equals("int16")) {\r
+ return new Int16(actualPath, namespace, revision);\r
+ } else if (typeName.equals("int32")) {\r
+ return new Int32(actualPath, namespace, revision);\r
+ } else if (typeName.equals("int64")) {\r
+ return new Int64(actualPath, namespace, revision);\r
+ }\r
+ } else if (typeName.startsWith("uint")) {\r
+ if (typeName.equals("uint8")) {\r
+ return new Uint8(actualPath, namespace, revision);\r
+ } else if (typeName.equals("uint16")) {\r
+ return new Uint16(actualPath, namespace, revision);\r
+ } else if (typeName.equals("uint32")) {\r
+ return new Uint32(actualPath, namespace, revision);\r
+ } else if (typeName.equals("uint64")) {\r
+ return new Uint64(actualPath, namespace, revision);\r
+ }\r
+ } else if (typeName.equals("string")) {\r
+ return new StringType(actualPath, namespace, revision);\r
}\r
- return null;\r
- }\r
\r
- public static TypeDefinition<UnsignedIntegerTypeDefinition> javaTypeForBaseYangUnsignedIntegerType(\r
- final String typeName, List<RangeConstraint> ranges) {\r
- if (typeName.equals("uint8")) {\r
- return new Uint8(ranges, null, null);\r
- } else if (typeName.equals("uint16")) {\r
- return new Uint16(ranges, null, null);\r
- } else if (typeName.equals("uint32")) {\r
- return new Uint32(ranges, null, null);\r
- } else if (typeName.equals("uint64")) {\r
- return new Uint64(ranges, null, null);\r
- }\r
- return null;\r
- }\r
-\r
- public static TypeDefinition<DecimalTypeDefinition> javaTypeForBaseYangDecimal64Type(\r
- List<RangeConstraint> rangeStatements, int fractionDigits) {\r
- return new Decimal64(rangeStatements, fractionDigits);\r
+ TypeDefinition<?> type = baseYangTypeMap.get(typeName);\r
+ return type;\r
}\r
\r
-}
+}\r