Updated yang java types constructors. Updated tests accordingly.
Change-Id: Ifeb1ddc96c89350579c837414dceeab624ef17ab
Signed-off-by: Martin Vitez <mvitez@cisco.com>
*/
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;
* @param maxRange
* @param units
*/
- public AbstractSignedInteger(final List<String> actualPath,
- final URI namespace, final Date revision, final QName name,
+ public AbstractSignedInteger(final SchemaPath path, 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(actualPath, namespace, revision);
+ this.path = path;
this.units = units;
this.rangeStatements = new ArrayList<RangeConstraint>();
final String rangeDescription = "Integer values between " + minRange
* @param rangeStatements
* @param units
*/
- public AbstractSignedInteger(final List<String> actualPath,
- final URI namespace, final Date revision, final QName name,
+ public AbstractSignedInteger(final SchemaPath path, final QName name,
final String description,
final List<RangeConstraint> rangeStatements, final String units) {
this.name = name;
this.description = description;
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
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;
* @param maxRange
* @param units
*/
- public AbstractUnsignedInteger(final List<String> actualPath,
- final URI namespace, final Date revision, final QName name,
+ public AbstractUnsignedInteger(final SchemaPath path, 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(actualPath, namespace, revision);
+ this.path = path;
this.units = units;
this.rangeStatements = new ArrayList<RangeConstraint>();
final String rangeDescription = "Integer values between " + minRange
* @param rangeStatements
* @param units
*/
- public AbstractUnsignedInteger(final List<String> actualPath,
- final URI namespace, final Date revision, final QName name,
+ public AbstractUnsignedInteger(final SchemaPath path, final QName name,
final String description,
final List<RangeConstraint> rangeStatements, final String units) {
this.name = name;
this.description = description;
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.units = units;
this.rangeStatements = rangeStatements;
}
/*
- * 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
- */
+ * 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.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;
*
* @see BinaryTypeDefinition
*/
-public class BinaryType implements BinaryTypeDefinition {
+public final class BinaryType implements BinaryTypeDefinition {
private final QName name = BaseTypes.constructQName("binary");
private final SchemaPath path;
super();
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
- constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
+ ""));
this.lengthConstraints = Collections.unmodifiableList(constraints);
this.bytes = Collections.emptyList();
this.path = BaseTypes.schemaPath(name);
this.baseType = this;
}
- public BinaryType(final List<String> actualPath, final URI namespace,
- final Date revision) {
+ public BinaryType(final SchemaPath path) {
super();
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
- constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
+ ""));
this.lengthConstraints = Collections.unmodifiableList(constraints);
this.bytes = Collections.emptyList();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new BinaryType();
}
* @param lengthConstraints
* @param units
*/
- public BinaryType(final List<String> actualPath, final URI namespace,
- final Date revision, final List<Byte> bytes,
+ public BinaryType(final SchemaPath path, final List<Byte> bytes,
final List<LengthConstraint> lengthConstraints, final String units) {
super();
if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) {
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
- constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE,
+ "", ""));
this.lengthConstraints = Collections.unmodifiableList(constraints);
} else {
- this.lengthConstraints = Collections.unmodifiableList(lengthConstraints);
+ this.lengthConstraints = Collections
+ .unmodifiableList(lengthConstraints);
}
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.bytes = Collections.unmodifiableList(bytes);
this.units = units;
this.baseType = new BinaryType();
/*
* (non-Javadoc)
*
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+ * @see
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
public BinaryTypeDefinition getBaseType() {
/*
* (non-Javadoc)
*
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+ * @see
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+ * ()
*/
@Override
public Object getDefaultValue() {
/*
* (non-Javadoc)
*
- * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
+ * @see
+ * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
*/
@Override
public String getDescription() {
* (non-Javadoc)
*
* @see
- * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition#getLengthConstraint
- * ()
+ * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition
+ * #getLengthConstraint ()
*/
@Override
public List<LengthConstraint> getLengthConstraints() {
+ ((description == null) ? 0 : description.hashCode());
result = prime
* result
- + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
+ + ((lengthConstraints == null) ? 0 : lengthConstraints
+ .hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((path == null) ? 0 : path.hashCode());
result = prime * result
*/
package org.opendaylight.controller.yang.model.util;
-import java.net.URI;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
*
* @see BitsTypeDefinition
*/
-public class BitsType implements BitsTypeDefinition {
+public final class BitsType implements BitsTypeDefinition {
private final QName name = BaseTypes.constructQName("bits");
private final SchemaPath path;
this.baseType = this;
}
- public BitsType(final List<String> actualPath, final URI namespace,
- final Date revision) {
+ public BitsType(final SchemaPath path) {
super();
this.bits = Collections.emptyList();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new BitsType();
}
* @param bits
* The bits assigned for Bits Type
*/
- public BitsType(final List<String> actualPath, final URI namespace,
- final Date revision, final List<Bit> bits) {
+ public BitsType(final SchemaPath path, final List<Bit> bits) {
super();
this.bits = Collections.unmodifiableList(bits);
this.units = "";
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new BitsType();
}
* @param units
* units for bits type
*/
- public BitsType(final List<String> actualPath, final URI namespace,
- final Date revision, List<Bit> bits, String units) {
+ public BitsType(final SchemaPath path, List<Bit> bits, String units) {
super();
this.bits = Collections.unmodifiableList(bits);
this.units = units;
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new BitsType();
}
*/
package org.opendaylight.controller.yang.model.util;
-import java.net.URI;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
*
* @see BooleanTypeDefinition
*/
-public class BooleanType implements BooleanTypeDefinition {
+public final class BooleanType implements BooleanTypeDefinition {
private final QName name = BaseTypes.constructQName("boolean");
private final SchemaPath path;
this.baseType = this;
}
- public BooleanType(final List<String> actualPath, final URI namespace,
- final Date revision) {
+ public BooleanType(final SchemaPath path) {
super();
this.defaultValue = false;
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new BooleanType();
}
* @param defaultValue
* Default Value
*/
- public BooleanType(final List<String> actualPath, final URI namespace,
- final Date revision, final Boolean defaultValue) {
+ public BooleanType(final SchemaPath path, final Boolean defaultValue) {
super();
this.defaultValue = defaultValue;
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new BooleanType();
}
* @param units
* Units
*/
- public BooleanType(final List<String> actualPath, final URI namespace,
- final Date revision, final Boolean defaultValue, final String units) {
+ public BooleanType(final SchemaPath path, final Boolean defaultValue, final String units) {
super();
this.defaultValue = defaultValue;
this.units = units;
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new BooleanType();
}
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;
*
* @see DecimalTypeDefinition
*/
-public class Decimal64 implements DecimalTypeDefinition {
+public final class Decimal64 implements DecimalTypeDefinition {
private final QName name = BaseTypes.constructQName("decimal64");
private final SchemaPath path;
this.baseType = this;
}
- public Decimal64(final List<String> actualPath, final URI namespace,
- final Date revision, final Integer fractionDigits) {
+ public Decimal64(final SchemaPath path, final Integer fractionDigits) {
super();
if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
throw new IllegalArgumentException(
}
this.fractionDigits = fractionDigits;
rangeStatements = defaultRangeStatements();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new Decimal64(fractionDigits);
}
* integer between 1 and 18 inclusively
* @exception IllegalArgumentException
*/
- public Decimal64(final List<String> actualPath, final URI namespace,
- final Date revision, final List<RangeConstraint> rangeStatements,
+ public Decimal64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
Integer fractionDigits) {
super();
if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
.unmodifiableList(rangeStatements);
}
this.fractionDigits = fractionDigits;
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.baseType = new Decimal64(fractionDigits);
}
* @param fractionDigits
* integer between 1 and 18 inclusively
*/
- public Decimal64(final List<String> actualPath, final URI namespace,
- final Date revision, final String units,
+ public Decimal64(final SchemaPath path, final String units,
final BigDecimal defaultValue,
final List<RangeConstraint> rangeStatements,
final Integer fractionDigits) {
this.units = units;
this.defaultValue = defaultValue;
this.fractionDigits = fractionDigits;
- this.path = BaseTypes.schemaPath(name);
+ this.path = path;
this.baseType = new Decimal64(fractionDigits);
}
*/
package org.opendaylight.controller.yang.model.util;
-import java.net.URI;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;
-public class EmptyType implements EmptyTypeDefinition {
+public final class EmptyType implements EmptyTypeDefinition {
private final QName name = BaseTypes.constructQName("empty");
private final SchemaPath path;
this.baseType = this;
}
- public EmptyType(final List<String> actualPath,
- final URI namespace, final Date revision) {
- path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ public EmptyType(final SchemaPath path) {
+ this.path = path;
this.baseType = new EmptyType();
}
*/
package org.opendaylight.controller.yang.model.util;
-import java.net.URI;
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 Enumertaion Type Definition interface.
- *
+ *
* @see EnumTypeDefinition
*/
-public class EnumerationType implements EnumTypeDefinition {
+public final class EnumerationType implements EnumTypeDefinition {
private final QName name = BaseTypes.constructQName("enumeration");
private final SchemaPath path;
private final List<EnumPair> enums;
private String units = "";
private final EnumTypeDefinition baseType;
-
+
private EnumerationType(final List<EnumPair> enums) {
this.path = BaseTypes.schemaPath(name);
this.enums = Collections.unmodifiableList(enums);
this.defaultEnum = null;
baseType = this;
}
-
- public EnumerationType(final List<String> actualPath, final URI namespace,
- final Date revision, final List<EnumPair> enums) {
+
+ public EnumerationType(final SchemaPath path, final List<EnumPair> enums) {
super();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.enums = Collections.unmodifiableList(enums);
this.defaultEnum = null;
baseType = new EnumerationType(enums);
}
- public EnumerationType(final List<String> actualPath, final URI namespace,
- final Date revision, final EnumTypeDefinition baseType, final EnumPair defaultEnum,
+ public EnumerationType(final SchemaPath path, final EnumPair defaultEnum,
final List<EnumPair> enums, final String units) {
super();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
- this.baseType = baseType;
+ this.path = path;
+ baseType = new EnumerationType(enums);
this.defaultEnum = defaultEnum;
this.enums = Collections.unmodifiableList(enums);
this.units = units;
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.base.type.api.EnumTypeDefinition#getValues()
*/
@Override
+++ /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.model.util;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.Status;
-import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.controller.yang.model.api.type.IdentityTypeDefinition;
-
-/**
- * The <code>default</code> implementation of Identity Type Definition interface.
- *
- * @see IdentityTypeDefinition
- */
-public class IdentityType implements IdentityTypeDefinition {
-
- private final QName name = BaseTypes.constructQName("identity");
- private final SchemaPath path = BaseTypes.schemaPath(name);
- private final String description = "The 'identity' statement is used to define a new " +
- "globally unique, abstract, and untyped identity.";
- private final String reference = "https://tools.ietf.org/html/rfc6020#section-7.16";
-
- private String units = "";
- private final QName identityName;
-
- public IdentityType(QName identityName) {
- super();
- this.identityName = identityName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
- */
- @Override
- public IdentityTypeDefinition getBaseType() {
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
- */
- @Override
- public String getUnits() {
- return units;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
- */
- @Override
- public Object getDefaultValue() {
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
- */
- @Override
- public QName getQName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
- */
- @Override
- public SchemaPath getPath() {
- return path;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
- */
- @Override
- public String getDescription() {
- return description;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
- */
- @Override
- public String getReference() {
- return reference;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
- */
- @Override
- public Status getStatus() {
- return Status.CURRENT;
- }
-
- @Override
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return Collections.emptyList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.opendaylight.controller.yang.model.base.type.api.IdentityTypeDefinition#getIdentityName
- * ()
- */
- @Override
- public QName getIdentityName() {
- return identityName;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((description == null) ? 0 : description.hashCode());
- result = prime * result
- + ((identityName == null) ? 0 : identityName.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- result = prime * result
- + ((reference == null) ? 0 : reference.hashCode());
- result = prime * result + ((units == null) ? 0 : units.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- IdentityType other = (IdentityType) obj;
- if (description == null) {
- if (other.description != null) {
- return false;
- }
- } else if (!description.equals(other.description)) {
- return false;
- }
- if (identityName == null) {
- if (other.identityName != null) {
- return false;
- }
- } else if (!identityName.equals(other.identityName)) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (path == null) {
- if (other.path != null) {
- return false;
- }
- } else if (!path.equals(other.path)) {
- return false;
- }
- if (reference == null) {
- if (other.reference != null) {
- return false;
- }
- } else if (!reference.equals(other.reference)) {
- return false;
- }
- if (units == null) {
- if (other.units != null) {
- return false;
- }
- } else if (!units.equals(other.units)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("IdentityType [name=");
- builder.append(name);
- builder.append(", path=");
- builder.append(path);
- builder.append(", description=");
- builder.append(description);
- builder.append(", reference=");
- builder.append(reference);
- builder.append(", units=");
- builder.append(units);
- builder.append(", identityName=");
- builder.append(identityName);
- builder.append("]");
- return builder.toString();
- }
-}
*/\r
package org.opendaylight.controller.yang.model.util;\r
\r
-import java.net.URI;\r
import java.util.Collections;\r
-import java.util.Date;\r
import java.util.List;\r
\r
import org.opendaylight.controller.yang.common.QName;\r
*\r
* @see IdentityrefTypeDefinition\r
*/\r
-public class IdentityrefType implements IdentityrefTypeDefinition {\r
+public final class IdentityrefType implements IdentityrefTypeDefinition {\r
\r
private final QName name = BaseTypes.constructQName("identityref");\r
private final SchemaPath path;\r
this.baseType = new IdentityrefType(identity);\r
}\r
\r
- public IdentityrefType(final List<String> actualPath,\r
- final URI namespace, final Date revision, final QName identity) {\r
- this.identity = identity;\r
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);\r
- this.baseType = new IdentityrefType(identity);\r
- }\r
-\r
@Override\r
public String getUnits() {\r
return units;\r
*/
package org.opendaylight.controller.yang.model.util;
-import java.net.URI;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
*
* @see InstanceIdentifierTypeDefinition
*/
-public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
+public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
private static final QName name = BaseTypes
.constructQName("instance-identifier");
this.baseType = this;
}
- public InstanceIdentifier(final List<String> actualPath, final URI namespace,
- final Date revision, RevisionAwareXPath xpath, boolean requireInstance) {
+ public InstanceIdentifier(final SchemaPath path, RevisionAwareXPath xpath, boolean requireInstance) {
super();
- path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.xpath = xpath;
this.requireInstance = requireInstance;
this.baseType = new InstanceIdentifier(xpath, requireInstance);
*/
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;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
*
* @see AbstractSignedInteger
*/
-public class Int16 extends AbstractSignedInteger {
+public final class Int16 extends AbstractSignedInteger {
private static final QName name = BaseTypes.constructQName("int16");
private Short defaultValue = null;
- private static final String description =
- "int16 represents integer values between -32768 and 32767, inclusively.";
+ private static final String description = "int16 represents integer values between -32768 and 32767, inclusively.";
private final IntegerTypeDefinition baseType;
private Int16() {
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Int16();
}
- public Int16(final List<String> actualPath, final URI namespace,
- final Date revision, final List<RangeConstraint> rangeStatements,
- final String units, final Short defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ public Int16(final SchemaPath path,
+ final List<RangeConstraint> rangeStatements, final String units,
+ final Short defaultValue) {
+ super(path, name, description, rangeStatements, units);
this.defaultValue = defaultValue;
this.baseType = new Int16();
}
*/
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;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
* @see AbstractSignedInteger
*
*/
-public class Int32 extends AbstractSignedInteger {
+public final class Int32 extends AbstractSignedInteger {
private static final QName name = BaseTypes.constructQName("int32");
private Integer defaultValue = null;
- private static final String description =
- "int32 represents integer values between -2147483648 and 2147483647, inclusively.";
+ private static final String description = "int32 represents integer values between -2147483648 and 2147483647, inclusively.";
private final IntegerTypeDefinition baseType;
private Int32() {
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
this.baseType = new Int32();
}
- 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, "");
+ public Int32(final SchemaPath path, final Integer defaultValue) {
+ super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
this.baseType = new Int32();
this.defaultValue = defaultValue;
}
- public Int32(final List<String> actualPath, final URI namespace,
- final Date revision, final List<RangeConstraint> rangeStatements,
- final String units, final Integer defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ public Int32(final SchemaPath path,
+ final List<RangeConstraint> rangeStatements, final String units,
+ final Integer defaultValue) {
+ super(path, name, description, rangeStatements, units);
this.baseType = new Int32();
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;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
* {@link Long}.
*
*/
-public class Int64 extends AbstractSignedInteger {
+public final class Int64 extends AbstractSignedInteger {
private static final QName name = BaseTypes.constructQName("int64");
private Long defaultValue = null;
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
this.baseType = new Int64();
}
- 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, "");
+ public Int64(final SchemaPath path, final Long defaultValue) {
+ super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
this.baseType = new Int64();
this.defaultValue = defaultValue;
}
- public Int64(final List<String> actualPath, final URI namespace,
- final Date revision, final List<RangeConstraint> rangeStatements,
+ public Int64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
final String units, final Long defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ super(path, name, description, rangeStatements, units);
this.baseType = new Int64();
this.defaultValue = defaultValue;
}
/*
- * 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
- */
+ * 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.model.util;
-import java.net.URI;
-import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
/**
- * Implementation of Yang int8 built-in type.
- * <br>
- * int8 represents integer values between -128 and 127, inclusively. The Java counterpart of
- * Yang int8 built-in type is {@link Byte}.
+ * Implementation of Yang int8 built-in type. <br>
+ * 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 {
+public final class Int8 extends AbstractSignedInteger {
private static final QName name = BaseTypes.constructQName("int8");
private Byte defaultValue = null;
- private static final String description =
- "represents integer values between -128 and 127, inclusively.";
+ private static final String description = "represents integer values between -128 and 127, inclusively.";
private final IntegerTypeDefinition baseType;
private Int8() {
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
this.baseType = new Int8();
}
- 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, "");
+ public Int8(final SchemaPath path, final Byte defaultValue) {
+ super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
this.baseType = new Int8();
this.defaultValue = defaultValue;
}
- public Int8(final List<String> actualPath, final URI namespace,
- final Date revision, final List<RangeConstraint> rangeStatements,
- final String units, final Byte defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ public Int8(final SchemaPath path,
+ final List<RangeConstraint> rangeStatements, final String units,
+ final Byte defaultValue) {
+ super(path, name, description, rangeStatements, units);
this.baseType = new Int8();
this.defaultValue = defaultValue;
}
/*
* (non-Javadoc)
*
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+ * @see
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
public IntegerTypeDefinition getBaseType() {
/*
* (non-Javadoc)
*
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
+ * @see
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
+ * ()
*/
@Override
public Object getDefaultValue() {
*/
package org.opendaylight.controller.yang.model.util;
-import java.net.URI;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
*
* @see LeafrefTypeDefinition
*/
-public class Leafref implements LeafrefTypeDefinition {
+public final class Leafref implements LeafrefTypeDefinition {
private static final QName name = BaseTypes.constructQName("leafref");
private static final String description = "The leafref type is used to reference a "
+ "particular leaf instance in the data tree.";
this.baseType = this;
}
- public Leafref(final List<String> actualPath, final URI namespace,
- final Date revision, final RevisionAwareXPath xpath) {
+ public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
super();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.xpath = xpath;
baseType = new Leafref(xpath);
}
- public Leafref(final List<String> actualPath, final URI namespace,
- final Date revision, final LeafrefTypeDefinition baseType,
- final RevisionAwareXPath xpath) {
- super();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
- this.xpath = xpath;
- this.baseType = baseType;
- }
-
/*
* (non-Javadoc)
*
import org.opendaylight.controller.yang.model.api.SchemaContext;
import org.opendaylight.controller.yang.model.api.SchemaNode;
import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
public final class SchemaContextUtil {
public static DataSchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
if (schemaPath != null) {
final Module module = resolveModuleFromSchemaPath(context, schemaPath);
- final Queue<QName> prefixedPath = new LinkedList<QName>(schemaPath.getPath());
+ final Queue<QName> prefixedPath = new LinkedList<QName>(schemaPath.getPath());
if ((module != null) && (prefixedPath != null)) {
return findSchemaNodeForGivenPath(context, module, prefixedPath);
final Queue<QName> qnamedPath = xpathToQNamePath(context, module,
strXPath);
if (qnamedPath != null) {
- final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
+ final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
module, qnamedPath);
return dataNode;
}
return null;
}
- public static DataSchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context,
+ public static DataSchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context,
final Module module, final SchemaNode actualSchemaNode,
final RevisionAwareXPath relativeXPath) {
if ((actualSchemaNode != null) && (relativeXPath != null)
final SchemaPath actualNodePath = actualSchemaNode.getPath();
if (actualNodePath != null) {
- final Queue<QName> qnamePath = resolveRelativeXPath(context, module,
+ final Queue<QName> qnamePath = resolveRelativeXPath(context, module,
relativeXPath, actualNodePath);
if (qnamePath != null) {
- final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
+ final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context,
module, qnamePath);
return dataNode;
}
public static Module resolveModuleFromSchemaPath(final SchemaContext context, final SchemaPath schemaPath) {
if ((schemaPath != null) && (schemaPath.getPath() != null)) {
- final QName qname = schemaPath.getPath().get(0);
+ List<QName> path = schemaPath.getPath();
+ final QName qname = path.get(path.size()-1);
if ((qname != null) && (qname.getNamespace() != null)) {
return context.findModuleByNamespace(qname.getNamespace());
return null;
}
+ public static Module resolveModuleFromTypePath(final SchemaContext context, final TypeDefinition<?> type) {
+ final SchemaPath schemaPath = type.getPath();
+ if ((schemaPath != null) && (schemaPath.getPath() != null)) {
+ if(type instanceof ExtendedType) {
+ List<QName> path = schemaPath.getPath();
+ final QName qname = path.get(path.size()-1);
+
+ if ((qname != null) && (qname.getNamespace() != null)) {
+ return context.findModuleByNamespace(qname.getNamespace());
+ }
+ } else {
+ LinkedList<QName> path = new LinkedList<QName>(schemaPath.getPath());
+ path.removeLast();
+ final QName qname = path.get(path.size()-1);
+
+ if ((qname != null) && (qname.getNamespace() != null)) {
+ return context.findModuleByNamespace(qname.getNamespace());
+ }
+ }
+
+ }
+ return null;
+ }
+
public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
if (context == null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
childNodeQName = qnamedPath.peek();
if (childNodeQName != null) {
final URI childNodeNamespace = childNodeQName.getNamespace();
-
+
schemaNode = nextNode.getDataChildByName(childNodeQName);
if (schemaNode != null) {
if (schemaNode instanceof ContainerSchemaNode) {
}
final List<QName> path = leafrefSchemaPath.getPath();
if (path != null) {
- int lenght = path.size() - colCount;
+ int lenght = path.size() - colCount - 1;
for (int i = 0; i < lenght; ++i) {
absolutePath.add(path.get(i));
}
*/
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;
*
* @see StringTypeDefinition
*/
-public class StringType implements StringTypeDefinition {
+public final class StringType implements StringTypeDefinition {
- private final QName name = BaseTypes.constructQName("string");;
+ private final QName name = BaseTypes.constructQName("string");
private final SchemaPath path;
private String defaultValue = "";
private final String description = "";
/**
* Default Constructor.
*/
- public StringType(final List<String> actualPath,
- final URI namespace, final Date revision) {
+ public StringType(final SchemaPath path) {
super();
- path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
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<String> actualPath,
- final URI namespace, final Date revision, final List<LengthConstraint> lengthStatements,
+ public StringType(final SchemaPath path, final List<LengthConstraint> lengthStatements,
final List<PatternConstraint> patterns) {
super();
- path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
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 List<String> actualPath,
- final URI namespace, final Date revision, final String defaultValue,
+ public StringType(final SchemaPath path, final String defaultValue,
final List<LengthConstraint> lengthStatements,
final List<PatternConstraint> patterns, final String units) {
super();
- this.path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
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;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
* counterpart of Yang uint32 built-in type is {@link Integer}.
*
*/
-public class Uint16 extends AbstractUnsignedInteger {
+public final class Uint16 extends AbstractUnsignedInteger {
private static final QName name = BaseTypes.constructQName("uint16");
private Integer defaultValue = null;
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint16();
}
- 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, "");
+ public Uint16(final SchemaPath path, final Integer defaultValue) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint16();
this.defaultValue = defaultValue;
}
- public Uint16(final List<String> actualPath,
- final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+ public Uint16(final SchemaPath path, final List<RangeConstraint> rangeStatements,
final String units, final Integer defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ super(path, name, description, rangeStatements, units);
this.baseType = new Uint16();
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;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
* Java counterpart of Yang uint32 built-in type is {@link Long}.
*
*/
-public class Uint32 extends AbstractUnsignedInteger {
+public final class Uint32 extends AbstractUnsignedInteger {
private static final QName name = BaseTypes.constructQName("uint32");
private Long defaultValue = null;
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint32();
}
- 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, "");
+ public Uint32(final SchemaPath path, final Long defaultValue) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint32();
this.defaultValue = defaultValue;
}
- public Uint32(final List<String> actualPath,
- final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+ public Uint32(final SchemaPath path, final List<RangeConstraint> rangeStatements,
final String units, final Long defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ super(path, name, description, rangeStatements, units);
this.baseType = new Uint32();
this.defaultValue = defaultValue;
}
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;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
* {@link BigInteger}.
*
*/
-public class Uint64 extends AbstractUnsignedInteger {
+public final class Uint64 extends AbstractUnsignedInteger {
private static final QName name = BaseTypes.constructQName("uint64");
private BigInteger defaultValue = null;
- private static final String description =
- "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
+ private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
private Uint64() {
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint64();
}
- 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, "");
+ public Uint64(final SchemaPath path, final BigInteger defaultValue) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint64();
this.defaultValue = defaultValue;
}
- public Uint64(final List<String> actualPath,
- final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
- final String units, final BigInteger defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ public Uint64(final SchemaPath path,
+ final List<RangeConstraint> rangeStatements, final String units,
+ final BigInteger defaultValue) {
+ super(path, name, description, rangeStatements, units);
this.baseType = new Uint64();
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;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
*
* @see AbstractUnsignedInteger
*/
-public class Uint8 extends AbstractUnsignedInteger {
+public final class Uint8 extends AbstractUnsignedInteger {
private static final QName name = BaseTypes.constructQName("uint8");
private Short defaultValue = null;
this.baseType = this;
}
- 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 SchemaPath path) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint8();
}
- 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, "");
+ public Uint8(final SchemaPath path, final Short defaultValue) {
+ super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
this.baseType = new Uint8();
this.defaultValue = defaultValue;
}
- public Uint8(final List<String> actualPath,
- final URI namespace, final Date revision, final List<RangeConstraint> rangeStatements,
+ public Uint8(final SchemaPath path, final List<RangeConstraint> rangeStatements,
final String units, final Short defaultValue) {
- super(actualPath, namespace, revision, name, description, rangeStatements, units);
+ super(path, name, description, rangeStatements, units);
this.baseType = new Uint8();
this.defaultValue = defaultValue;
}
/*
- * 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
- */
+ * 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.model.util;
-import java.net.URI;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
import org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
-public class UnionType implements UnionTypeDefinition {
+public final class UnionType implements UnionTypeDefinition {
private final QName name = BaseTypes.constructQName("union");
private final SchemaPath path;
private final List<TypeDefinition<?>> types;
private UnionType(List<TypeDefinition<?>> types) {
- if(types == null) {
- throw new NullPointerException("When the type is 'union', the 'type' statement MUST be present.");
+ if (types == null) {
+ throw new NullPointerException(
+ "When the type is 'union', the 'type' statement MUST be present.");
}
path = BaseTypes.schemaPath(name);
this.types = types;
this.baseType = this;
}
- public UnionType(final List<String> actualPath, final URI namespace,
- final Date revision, List<TypeDefinition<?>> types) {
- if(types == null) {
- throw new NullPointerException("When the type is 'union', the 'type' statement MUST be present.");
+ public UnionType(final SchemaPath path, List<TypeDefinition<?>> types) {
+ if (types == null) {
+ throw new NullPointerException(
+ "When the type is 'union', the 'type' statement MUST be present.");
}
- path = BaseTypes.schemaPath(actualPath, namespace, revision);
+ this.path = path;
this.types = types;
this.baseType = new UnionType(types);
}
builder.append("UnionType [name=");
builder.append(name);
builder.append(", types=[");
- for(TypeDefinition<?> td : types) {
- builder.append(", "+ td.getQName().getLocalName());
+ for (TypeDefinition<?> td : types) {
+ builder.append(", " + td.getQName().getLocalName());
}
builder.append("]");
builder.append("]");
package org.opendaylight.controller.yang.model.util;\r
\r
import java.net.URI;\r
+import java.util.ArrayList;\r
import java.util.Date;\r
import java.util.HashSet;\r
import java.util.List;\r
import java.util.Set;\r
\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
\r
-public class YangTypesConverter {\r
+public final class YangTypesConverter {\r
private static final Set<String> baseYangTypes = new HashSet<String>();\r
\r
static {\r
String typeName) {\r
TypeDefinition<?> type = null;\r
\r
+ SchemaPath path = createSchemaPath(actualPath, namespace, revision);\r
if (typeName.startsWith("int")) {\r
if (typeName.equals("int8")) {\r
- type = new Int8(actualPath, namespace, revision);\r
+ type = new Int8(path);\r
} else if (typeName.equals("int16")) {\r
- type = new Int16(actualPath, namespace, revision);\r
+ type = new Int16(path);\r
} else if (typeName.equals("int32")) {\r
- type = new Int32(actualPath, namespace, revision);\r
+ type = new Int32(path);\r
} else if (typeName.equals("int64")) {\r
- type = new Int64(actualPath, namespace, revision);\r
+ type = new Int64(path);\r
}\r
} else if (typeName.startsWith("uint")) {\r
if (typeName.equals("uint8")) {\r
- type = new Uint8(actualPath, namespace, revision);\r
+ type = new Uint8(path);\r
} else if (typeName.equals("uint16")) {\r
- type = new Uint16(actualPath, namespace, revision);\r
+ type = new Uint16(path);\r
} else if (typeName.equals("uint32")) {\r
- type = new Uint32(actualPath, namespace, revision);\r
+ type = new Uint32(path);\r
} else if (typeName.equals("uint64")) {\r
- type = new Uint64(actualPath, namespace, revision);\r
+ type = new Uint64(path);\r
}\r
} else if ("string".equals(typeName)) {\r
- type = new StringType(actualPath, namespace, revision);\r
+ type = new StringType(path);\r
} else if("binary".equals(typeName)) {\r
- type = new BinaryType(actualPath, namespace, revision);\r
+ type = new BinaryType(path);\r
} else if("boolean".equals(typeName)) {\r
- type = new BooleanType(actualPath, namespace, revision);\r
+ type = new BooleanType(path);\r
} else if("empty".equals(typeName)) {\r
- type = new EmptyType(actualPath, namespace, revision);\r
+ type = new EmptyType(path);\r
} else if("instance-identifier".equals(typeName)) {\r
- type = new InstanceIdentifier(actualPath, namespace, revision, null, true);\r
+ type = new InstanceIdentifier(path, null, true);\r
}\r
\r
return type;\r
}\r
\r
+ private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision) {\r
+ List<QName> path = new ArrayList<QName>();\r
+ for(String element : actualPath) {\r
+ path.add(new QName(namespace, revision, element));\r
+ }\r
+ return new SchemaPath(path, true);\r
+ }\r
+\r
}\r