### Question:
Numbers { @SuppressWarnings("unchecked") @Contract(value = "_,!null -> !null; _,null -> null", pure = true) public static <N extends Number> N convertNumber(final Class<N> numberClass, final Number number) { if (number == null) return null; if (numberClass.isAssignableFrom(number.getClass())) return (N) number; if (numberClass == Byte.class || numberClass == byte.class) return (N) new Byte(number.byteValue()); if (numberClass == Short.class || numberClass == short.class) return (N) new Short(number.shortValue()); if (numberClass == Integer.class || numberClass == int.class) return (N) new Integer(number.intValue()); if (numberClass == Long.class || numberClass == long.class) return (N) new Long(number.longValue()); if (numberClass == Float.class || numberClass == float.class) return (N) new Float(number.floatValue()); if (numberClass == Double.class || numberClass == double.class) return (N) new Double(number.doubleValue()); if (numberClass == BigInteger.class) return (N) new BigInteger(number.toString()); if (numberClass == BigDecimal.class) return (N) new BigDecimal(number.toString()); String message = String.format("Unknown how to convert value (%s) of type %s to %s.", number.toString(), number.getClass().getCanonicalName(), numberClass.getCanonicalName()); throw new IllegalArgumentException(message); }  static boolean valuesAreEqual(@Nullable final Number x, @Nullable final Number y); @SuppressWarnings("unchecked") @Contract(value = "_,!null -> !null; _,null -> null", pure = true) static N convertNumber(final Class<N> numberClass, final Number number); @Contract(value = "!null -> !null; null -> null", pure = true) static Number convertNumberSmartly(final BigDecimal decimal); static int parseIntSafe(@Nullable final String str); static long parseLongSafe(@Nullable final String str); static final Byte BYTE_ZERO; static final BigDecimal DECIMAL_ZERO; static final BigDecimal DECIMAL_MIN_LONG; static final BigDecimal DECIMAL_MAX_LONG; }### Answer:
@TestWithParams(params = "CONVERT_CASES") public void convert_basic(Number number, Class<Number> toClass) { Number convertedNumber = Numbers.convertNumber(toClass, number); assertThat(convertedNumber).isNotNull() .isExactlyInstanceOf(toClass); String originalString = removeEnding(number.toString(), ".0"); String convertedString = removeEnding(convertedNumber.toString(),".0"); assertThat(convertedString).isEqualTo(originalString); }