2 * Copyright (c) 2015 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.sal.java.api.generator;
10 import java.math.BigInteger;
12 final class BigIntegerRangeGenerator extends AbstractBigRangeGenerator<BigInteger> {
13 BigIntegerRangeGenerator() {
14 super(BigInteger.class);
18 protected String format(final BigInteger value) {
19 if (BigInteger.ZERO.equals(value)) {
20 return "java.math.BigInteger.ZERO";
22 if (BigInteger.ONE.equals(value)) {
23 return "java.math.BigInteger.ONE";
25 if (BigInteger.TEN.equals(value)) {
26 return "java.math.BigInteger.TEN";
29 // Check for conversion to long
30 final long l = value.longValue();
31 if (value.equals(BigInteger.valueOf(l))) {
32 return "java.math.BigInteger.valueOf(" + l + "L)";
34 return "new java.math.BigInteger(\"" + value.toString() + "\")";
39 protected BigInteger convert(final Number value) {
40 return BigInteger.valueOf(value.longValue());