Fixed base range constraints of yang uint built-in types. Made rpc input and output statement optional.
Changed formatting of files to conform new sun_coding_style template. Added more tests.
Signed-off-by: Martin Vitez <mvitez@cisco.com>
* @return ChoiceCaseNode objects defined in this node
*/
Set<ChoiceCaseNode> getCases();
+
+ String getDefaultCase();
}
* 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:
- *
+ *
* <ul>
* <li>uint8 - represents integer values between 0 and 255, inclusively.</li>
* <li>uint16 - represents integer values between 0 and 65535, inclusively.</li>
* <li>uint64 - represents integer values between 0 and 18446744073709551615,
* inclusively.</li>
* </ul>
- *
+ *
*/
-public abstract class AbstractUnsignedInteger implements
- UnsignedIntegerTypeDefinition {
+public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefinition {
+ private static final long MIN_VALUE = 0;
private final QName name;
private final SchemaPath path;
private final String description;
private final List<RangeConstraint> rangeStatements;
/**
- *
+ *
* @param actualPath
* @param namespace
* @param revision
* @param name
* @param description
- * @param minRange
+ * @param MIN_VALUE
* @param maxRange
* @param units
*/
- public AbstractUnsignedInteger(final SchemaPath path, final QName name,
- final String description, final Number minRange,
+ public AbstractUnsignedInteger(final SchemaPath path, final QName name, final String description,
final Number maxRange, final String units) {
this.name = name;
this.description = description;
this.path = path;
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,
+ final String rangeDescription = "Integer values between " + MIN_VALUE + " and " + maxRange + ", inclusively.";
+ this.rangeStatements.add(BaseConstraints.rangeConstraint(MIN_VALUE, maxRange, rangeDescription,
"https://tools.ietf.org/html/rfc6020#section-9.2.4"));
}
* @param rangeStatements
* @param units
*/
- public AbstractUnsignedInteger(final SchemaPath path, final QName name,
- final String description,
+ public AbstractUnsignedInteger(final SchemaPath path, final QName name, final String description,
final List<RangeConstraint> rangeStatements, final String units) {
this.name = name;
this.description = description;
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result
- + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((path == null) ? 0 : path.hashCode());
- result = prime * result
- + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
- result = prime * result
- + ((reference == null) ? 0 : reference.hashCode());
+ result = prime * result + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
+ result = prime * result + ((reference == null) ? 0 : reference.hashCode());
result = prime * result + ((units == null) ? 0 : units.hashCode());
return result;
}
*
*/
public final class Uint16 extends AbstractUnsignedInteger {
+ public static final int MAX_VALUE = 65535;
private static final QName name = BaseTypes.constructQName("uint16");
private Integer defaultValue = null;
private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
public Uint16(final SchemaPath path) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ super(path, name, description, MAX_VALUE, "");
this.baseType = this;
}
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = prime * result
- + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+ result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
return result;
}
builder.append("]");
return builder.toString();
}
+
}
/**
* 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}.
+ * uint32 represents integer values between 0 and 4294967295, inclusively.
*
*/
public final class Uint32 extends AbstractUnsignedInteger {
+ public static final long MAX_VALUE = 4294967295L;
private static final QName name = BaseTypes.constructQName("uint32");
private final Long defaultValue = null;
private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
public Uint32(final SchemaPath path) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ super(path, name, description, MAX_VALUE, "");
this.baseType = this;
}
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = prime * result
- + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+ result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
return result;
}
builder.append("]");
return builder.toString();
}
+
}
*
*/
public final class Uint64 extends AbstractUnsignedInteger {
+ public static final BigInteger MAX_VALUE = new BigInteger("18446744073709551615");
private static final QName name = BaseTypes.constructQName("uint64");
private final BigInteger defaultValue = null;
private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
public Uint64(final SchemaPath path) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ super(path, name, description, MAX_VALUE, "");
this.baseType = this;
}
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = prime * result
- + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+ result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
return result;
}
builder.append("]");
return builder.toString();
}
+
}
/*
- * 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 org.opendaylight.controller.yang.common.QName;
import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
/**
- * Implementation of Yang uint8 built-in type.
- * <br>
- * uint8 represents integer values between 0 and 255, inclusively. The Java counterpart of
- * Yang uint8 built-in type is {@link Short}.
+ * Implementation of Yang uint8 built-in type. <br>
+ * uint8 represents integer values between 0 and 255, inclusively.
*
* @see AbstractUnsignedInteger
*/
public final class Uint8 extends AbstractUnsignedInteger {
-
+ public static final int MAX_VALUE = 255;
private static final QName name = BaseTypes.constructQName("uint8");
private final Short defaultValue = null;
- private static final String description =
- "uint8 represents integer values between 0 and 255, inclusively.";
+ private static final String description = "uint8 represents integer values between 0 and 255, inclusively.";
private final UnsignedIntegerTypeDefinition baseType;
public Uint8(final SchemaPath path) {
- super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
+ super(path, name, description, MAX_VALUE, "");
this.baseType = this;
}
/*
* (non-Javadoc)
*
- * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
+ * @see
+ * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
public UnsignedIntegerTypeDefinition 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() {
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
- result = prime * result
- + ((defaultValue == null) ? 0 : defaultValue.hashCode());
+ result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
return result;
}
builder.append("]");
return builder.toString();
}
+
}