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;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.common.YangConstants;
16 * Contains methods for getting data from the YANG <code>type</code> substatement for <code>decimal64</code> built-in
19 public interface DecimalTypeDefinition extends RangeRestrictedTypeDefinition<DecimalTypeDefinition, BigDecimal> {
21 * Well-known QName of the {@code decimal64} built-in type.
23 QName QNAME = QName.create(YangConstants.RFC6020_YANG_MODULE, "decimal64").intern();
26 * Returns integer between 1 and 18 inclusively.
29 * The "fraction-digits" statement controls the size of the minimum difference between values of a decimal64 type,
30 * by restricting the value space to numbers that are expressible as "i x 10^-n" where n is the fraction-digits
33 * @return number of fraction digits
35 int getFractionDigits();
37 static int hashCode(final DecimalTypeDefinition type) {
38 return Objects.hash(type.getQName(), type.getUnknownSchemaNodes(), type.getBaseType(),
39 type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getFractionDigits(),
40 type.getRangeConstraint().orElse(null));
43 static boolean equals(final DecimalTypeDefinition type, final Object obj) {
48 final DecimalTypeDefinition other = TypeDefinitions.castIfEquals(DecimalTypeDefinition.class, type, obj);
49 return other != null && type.getFractionDigits() == other.getFractionDigits()
50 && type.getRangeConstraint().equals(other.getRangeConstraint());
53 static String toString(final DecimalTypeDefinition type) {
54 return TypeDefinitions.toStringHelper(type).add("fractionDigits", type.getFractionDigits()).toString();