/** * Returns the number of bits used by primitive of the specified type. * The given type must be a primitive type or its wrapper class. * * @param type the primitive type (may be {@code null}). * @return the number of bits, or 0 if {@code type} is null. * @throws IllegalArgumentException if the given type is unknown. */ public static int primitiveBitCount(final Class<?> type) throws IllegalArgumentException { final Numbers mapping = MAPPING.get(type); if (mapping != null) { final int size = mapping.size; if (size >= 0) { return size; } } if (type == null) { return 0; } throw unknownType(type); }
/** * Returns the number of bits used by primitive of the specified type. * The given type must be a primitive type or its wrapper class. * * @param type the primitive type (may be {@code null}). * @return the number of bits, or 0 if {@code type} is null. * @throws IllegalArgumentException if the given type is unknown. */ public static int primitiveBitCount(final Class<?> type) throws IllegalArgumentException { final Numbers mapping = MAPPING.get(type); if (mapping != null) { final int size = mapping.size; if (size >= 0) { return size; } } if (type == null) { return 0; } throw unknownType(type); }
final Numbers m1 = MAPPING.get(c1); if (m1 == null) { throw unknownType(c1); throw unknownType(c2);
final Numbers m1 = MAPPING.get(c1); if (m1 == null) { throw unknownType(c1); throw unknownType(c2);
final Numbers m1 = MAPPING.get(c1); if (m1 == null) { throw unknownType(c1); throw unknownType(c2);
final Numbers m1 = MAPPING.get(c1); if (m1 == null) { throw unknownType(c1); throw unknownType(c2);
case BIG_INTEGER: return (N) BigInteger.valueOf(value); // No need to verify. case BIG_DECIMAL: return (N) BigDecimal.valueOf(value); // No need to verify. default: throw unknownType(type);
case BIG_INTEGER: number = (N) BigInteger.valueOf((long) value); break; case BIG_DECIMAL: return (N) BigDecimal.valueOf(value); // No need to verify. default: throw unknownType(type);
case BIG_INTEGER: return (T) new BigInteger(value); case BIG_DECIMAL: return (T) new BigDecimal(value); default: throw unknownType(type);
case BIG_INTEGER: number = (N) BigInteger.valueOf((long) value); break; case BIG_DECIMAL: return (N) BigDecimal.valueOf(value); // No need to verify. default: throw unknownType(type);
case BIG_INTEGER: return (T) new BigInteger(value); case BIG_DECIMAL: return (T) new BigDecimal(value); default: throw unknownType(type);
case BIG_INTEGER: return (N) BigInteger.valueOf(value); // No need to verify. case BIG_DECIMAL: return (N) BigDecimal.valueOf(value); // No need to verify. default: throw unknownType(type);
return (N) number; throw unknownType(type);
return (N) number; throw unknownType(type);