2 * Copyright (c) 2015 Pantheon Technologies s.r.o. 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.ri.type;
10 import static com.google.common.base.Preconditions.checkState;
12 import org.opendaylight.yangtools.yang.common.Decimal64;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
16 public final class DecimalTypeBuilder extends RangeRestrictedTypeBuilder<DecimalTypeDefinition, Decimal64> {
17 private Integer fractionDigits;
19 DecimalTypeBuilder(final QName qname) {
23 public DecimalTypeBuilder setFractionDigits(final int fractionDigits) {
24 checkState(this.fractionDigits == null, "Fraction digits already defined to %s", this.fractionDigits);
25 this.fractionDigits = fractionDigits;
30 DecimalTypeDefinition buildType() {
31 checkState(fractionDigits != null, "Fraction digits not defined");
32 return new BaseDecimalType(getQName(), getUnknownSchemaNodes(), fractionDigits,
33 calculateRangeConstraint(BaseDecimalType.constraintsForDigits(fractionDigits)));