question: public static Number coerceBoxed ( Number numToCoerce , Class resultBoxedType ) { if ( numToCoerce . getClass ( ) == resultBoxedType ) { return numToCoerce ; } if ( resultBoxedType == Double . class ) { return numToCoerce . doubleValue ( ) ; } if ( resultBoxedType == Long . class ) { return numToCoerce . longValue ( ) ; } if ( resultBoxedType == BigInteger . class ) { return BigInteger . valueOf ( numToCoerce . longValue ( ) ) ; } if ( resultBoxedType == BigDecimal . class ) { if ( JavaClassHelper . isFloatingPointNumber ( numToCoerce ) ) { return new BigDecimal ( numToCoerce . doubleValue ( ) ) ; } return new BigDecimal ( numToCoerce . longValue ( ) ) ; } if ( resultBoxedType == Float . class ) { return numToCoerce . floatValue ( ) ; } if ( resultBoxedType == Integer . class ) { return numToCoerce . intValue ( ) ; } if ( resultBoxedType == Short . class ) { return numToCoerce . shortValue ( ) ; } if ( resultBoxedType == Byte . class ) { return numToCoerce . byteValue ( ) ; } throw new IllegalArgumentException ( "Cannot coerce to number subtype " + resultBoxedType . getName ( ) ) ; }
target:  Coerce the given number to the given type, assuming the type is a Boxed type. Allows coerce to lower resultion number. Does't coerce to primitive types. <p> Meant for statement compile-time use, not for runtime use.