import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
+import com.google.common.base.Optional;
+
/**
* The <code>default</code> implementation of Decimal Type Definition interface.
*
* @see DecimalTypeDefinition
*/
public final class Decimal64 implements DecimalTypeDefinition {
- private final QName name = BaseTypes.constructQName("decimal64");
+ private static final QName NAME = BaseTypes.DECIMAL64_QNAME;
private final SchemaPath path;
private static final String UNITS = "";
private static final BigDecimal DEFAULT_VALUE = null;
- private final String description = "The decimal64 type represents a subset of the real numbers, which can "
+ private static final String DESCRIPTION = "The decimal64 type represents a subset of the real numbers, which can "
+ "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "
+ "be obtained by multiplying a 64-bit signed integer by a negative power of ten, i.e., expressible as "
+ "'i x 10^-n' where i is an integer64 and n is an integer between 1 and 18, inclusively.";
*
* @see DecimalTypeDefinition
* @exception IllegalArgumentException
+ * @deprecated Use static factory {@link #create(SchemaPath, Integer)}.
*/
+ @Deprecated
public Decimal64(final SchemaPath path, final Integer fractionDigits) {
if (!((fractionDigits.intValue() >= 1) && (fractionDigits.intValue() <= MAX_NUMBER_OF_FRACTION_DIGITS))) {
throw new IllegalArgumentException(
this.path = path;
}
+ public static Decimal64 create(final SchemaPath path, final Integer fractionDigits) {
+ return new Decimal64(path, fractionDigits);
+ }
+
/**
* Returns unmodifiable List with default definition of Range Statements.
*
final BigDecimal min = new BigDecimal("-922337203685477580.8");
final BigDecimal max = new BigDecimal("922337203685477580.7");
final String rangeDescription = "Integer values between " + min + " and " + max + ", inclusively.";
- rangeStmts.add(BaseConstraints.rangeConstraint(min, max, rangeDescription,
- "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
+ rangeStmts.add(BaseConstraints.newRangeConstraint(min, max, Optional.of(rangeDescription),
+ Optional.of("https://tools.ietf.org/html/rfc6020#section-9.2.4")));
return Collections.unmodifiableList(rangeStmts);
}
@Override
public QName getQName() {
- return name;
+ return NAME;
}
@Override
@Override
public String getDescription() {
- return description;
+ return DESCRIPTION;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((NAME == null) ? 0 : NAME.hashCode());
result = prime * result + ((path == null) ? 0 : path.hashCode());
return result;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
return false;
}
Decimal64 other = (Decimal64) obj;
- 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;
@Override
public String toString() {
- return Decimal64.class.getSimpleName() + "[qname=" + name + ", fractionDigits=" + fractionDigits + "]";
+ return Decimal64.class.getSimpleName() + "[qname=" + NAME + ", fractionDigits=" + fractionDigits + "]";
}
}