@Test public void testConvert() { Object[][] testCases = { {new Long(17), 17L}, {new Integer(50), 50L}, {null, null}, {"", null}, {" ", null}, {"123", 123L} }; for (Object[] testCase : testCases) { Object obj = testCase[0]; Long expectedValue = (Long) testCase[1]; ValueHolder holder = TypeDecoder.convert(type, obj); assertEquals(expectedValue, holder.getValue()); } }
public static ValueHolder convert(Type<?> type, Object obj) { try { return type.convert(obj); } catch (RuntimeException exception) { throw new TypeConversionException(exception, obj, type); } }
TypeDecoder { public static ValueHolder convert(Type<?> type, Object obj) { try { return type.convert(obj); } catch (RuntimeException exception) { throw new TypeConversionException(exception, obj, type); } } }
TypeDecoder { public static ValueHolder convert(Type<?> type, Object obj) { try { return type.convert(obj); } catch (RuntimeException exception) { throw new TypeConversionException(exception, obj, type); } } private  TypeDecoder(); }
TypeDecoder { public static ValueHolder convert(Type<?> type, Object obj) { try { return type.convert(obj); } catch (RuntimeException exception) { throw new TypeConversionException(exception, obj, type); } } private  TypeDecoder(); static ValueHolder decode(Type<?> type, String text); static ValueHolder convert(Type<?> type, Object obj); static ValueHolder[] convert(Type<?> type, Object[] array); static ValueHolder[] convert(Type<?> type, Collection<?> coll); }
TypeDecoder { public static ValueHolder convert(Type<?> type, Object obj) { try { return type.convert(obj); } catch (RuntimeException exception) { throw new TypeConversionException(exception, obj, type); } } private  TypeDecoder(); static ValueHolder decode(Type<?> type, String text); static ValueHolder convert(Type<?> type, Object obj); static ValueHolder[] convert(Type<?> type, Object[] array); static ValueHolder[] convert(Type<?> type, Collection<?> coll);  }