OLD | NEW |
(Empty) | |
| 1 // © 2017 and later: Unicode, Inc. and others. |
| 2 // License & terms of use: http://www.unicode.org/copyright.html#License |
| 3 package com.ibm.icu.impl.number; |
| 4 |
| 5 import java.math.BigDecimal; |
| 6 import java.math.BigInteger; |
| 7 |
| 8 /** @author sffc */ |
| 9 public class FormatQuantitySelector { |
| 10 public static FormatQuantityBCD from(int input) { |
| 11 return new FormatQuantity4(input); |
| 12 } |
| 13 |
| 14 public static FormatQuantityBCD from(long input) { |
| 15 return new FormatQuantity4(input); |
| 16 } |
| 17 |
| 18 public static FormatQuantityBCD from(double input) { |
| 19 return new FormatQuantity4(input); |
| 20 } |
| 21 |
| 22 public static FormatQuantityBCD from(BigInteger input) { |
| 23 return new FormatQuantity4(input); |
| 24 } |
| 25 |
| 26 public static FormatQuantityBCD from(BigDecimal input) { |
| 27 return new FormatQuantity4(input); |
| 28 } |
| 29 |
| 30 public static FormatQuantityBCD from(com.ibm.icu.math.BigDecimal input) { |
| 31 return from(input.toBigDecimal()); |
| 32 } |
| 33 |
| 34 public static FormatQuantityBCD from(Number number) { |
| 35 if (number instanceof Long) { |
| 36 return from(number.longValue()); |
| 37 } else if (number instanceof Integer) { |
| 38 return from(number.intValue()); |
| 39 } else if (number instanceof Double) { |
| 40 return from(number.doubleValue()); |
| 41 } else if (number instanceof BigInteger) { |
| 42 return from((BigInteger) number); |
| 43 } else if (number instanceof BigDecimal) { |
| 44 return from((BigDecimal) number); |
| 45 } else if (number instanceof com.ibm.icu.math.BigDecimal) { |
| 46 return from((com.ibm.icu.math.BigDecimal) number); |
| 47 } else { |
| 48 throw new IllegalArgumentException( |
| 49 "Number is of an unsupported type: " + number.getClass().getName()); |
| 50 } |
| 51 } |
| 52 } |
OLD | NEW |