2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.api.type;
10 import java.math.BigDecimal;
11 import java.util.Objects;
14 * Contains methods for getting data from the YANG <code>type</code> substatement for <code>decimal64</code> built-in
17 public interface DecimalTypeDefinition extends RangeRestrictedTypeDefinition<DecimalTypeDefinition, BigDecimal> {
19 * Returns integer between 1 and 18 inclusively.
22 * The "fraction-digits" statement controls the size of the minimum
23 * difference between values of a decimal64 type, by restricting the value
24 * space to numbers that are expressible as "i x 10^-n" where n is the
25 * fraction-digits argument.
27 * @return number of fraction digits
29 int getFractionDigits();
31 static int hashCode(final DecimalTypeDefinition type) {
32 return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
33 type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getFractionDigits(),
34 type.getRangeConstraint().orElse(null));
37 static boolean equals(final DecimalTypeDefinition type, final Object obj) {
42 final DecimalTypeDefinition other = TypeDefinitions.castIfEquals(DecimalTypeDefinition.class, type, obj);
43 return other != null && type.getFractionDigits() == other.getFractionDigits()
44 && type.getRangeConstraint().equals(other.getRangeConstraint());
47 static String toString(final DecimalTypeDefinition type) {
48 return TypeDefinitions.toStringHelper(type).add("fractionDigits", type.getFractionDigits()).toString();