### Question:
TypeUtils { public static float castToFloat(@Nonnull Object value) { requireNonNull(value, ERROR_VALUE_NULL); if (value instanceof Number) { return ((Number) value).floatValue(); } return Float.valueOf(String.valueOf(value)); } private  TypeUtils(); static boolean castToBoolean(@Nonnull Object value); static char castToChar(@Nonnull Object value); static byte castToByte(@Nonnull Object value); static short castToShort(@Nonnull Object value); static int castToInt(@Nonnull Object value); static long castToLong(@Nonnull Object value); static float castToFloat(@Nonnull Object value); static double castToDouble(@Nonnull Object value); static BigInteger castToBigInteger(@Nonnull Object value); static BigDecimal castToBigDecimal(@Nonnull Object value); @Nullable static Number castToNumber(@Nonnull Object value); static boolean castToBoolean(@Nullable Object value, boolean defaultValue); static char castToChar(@Nullable Object value, char defaultValue); static byte castToByte(@Nullable Object value, byte defaultValue); static short castToShort(@Nullable Object value, short defaultValue); static int castToInt(@Nullable Object value, int defaultValue); static long castToLong(@Nullable Object value, long defaultValue); static float castToFloat(@Nullable Object value, float defaultValue); static double castToDouble(@Nullable Object value, double defaultValue); @Nullable static Number castToNumber(@Nullable Object value, @Nullable Number defaultValue); @Nullable static BigInteger castToBigInteger(@Nullable Object value, @Nullable BigInteger defaultValue); @Nullable static BigDecimal castToBigDecimal(@Nullable Object value, @Nullable BigDecimal defaultValue); @Nonnull static T convertValue(@Nonnull Class<T> targetType, @Nonnull Object value); @Nonnull @SuppressWarnings("unchecked") static T convertValue(@Nonnull Class<T> targetType, @Nonnull Object value, @Nullable String format); static boolean isBoolean(@Nonnull Class<?> type); static boolean isCharacter(@Nonnull Class<?> type); static boolean isByte(@Nonnull Class<?> type); static boolean isShort(@Nonnull Class<?> type); static boolean isInteger(@Nonnull Class<?> type); static boolean isLong(@Nonnull Class<?> type); static boolean isFloat(@Nonnull Class<?> type); static boolean isDouble(@Nonnull Class<?> type); static boolean isBigInteger(@Nonnull Class<?> type); static boolean isBigDecimal(@Nonnull Class<?> type); static boolean isNumber(@Nonnull Class<?> type); static boolean equals(@Nullable Object left, @Nullable Object right); static boolean arrayEqual(@Nullable Object left, @Nullable Object right); static boolean equals(int[] left, int[] right); static boolean equals(Object[] left, List right); static boolean equals(List left, Object[] right); static boolean equals(List<T> left, List<T> right); static boolean equals(Set<T> left, Set<T> right); static boolean equals(Map<K, V> left, Map<K, V> right); static List primitiveArrayToList(Object array); @SuppressWarnings("unchecked") static int compareTo(Object left, Object right); static int compareTo(Character left, Number right); static int compareTo(Number left, Character right); static int compareTo(Character left, Character right); static int compareTo(Number left, Number right); static boolean isFloatingPoint(Number number); static boolean isInteger(Number number); static boolean isLong(Number number); static boolean isBigDecimal(Number number); static boolean isBigInteger(Number number);  }### Answer:
@Test public void castToFloat() { assertEquals(10f, TypeUtils.castToFloat(Integer.valueOf("10")), 0f); assertEquals(10f, TypeUtils.castToFloat(Float.valueOf("10")), 0f); assertEquals(10f, TypeUtils.castToFloat("10"), 0f); assertEquals(10f, TypeUtils.castToFloat("10", 10f), 0f); assertEquals(10f, TypeUtils.castToFloat(null, 10f), 0f); }