@Test public void testDecode() { Object[][] testCases = { {"0", new IntegerHolder(0L)}, {" -99", new IntegerHolder(-99L)}, {null, new IntegerHolder(null)}, {"\t \n", new IntegerHolder(null)} }; for (Object[] testCase : testCases) { String text = (String) testCase[0]; ValueHolder expectedHolder = (ValueHolder) testCase[1]; ValueHolder holder = TypeDecoder.decode(type, text); assertEquals(expectedHolder.getValue(), holder.getValue()); } }
public static ValueHolder decode(Type<?> type, String text) { try { return type.decode(text != null ? text.trim() : null); } catch (RuntimeException exception) { throw new TypeDecodingException(exception, text, type); } }
TypeDecoder { public static ValueHolder decode(Type<?> type, String text) { try { return type.decode(text != null ? text.trim() : null); } catch (RuntimeException exception) { throw new TypeDecodingException(exception, text, type); } } }
TypeDecoder { public static ValueHolder decode(Type<?> type, String text) { try { return type.decode(text != null ? text.trim() : null); } catch (RuntimeException exception) { throw new TypeDecodingException(exception, text, type); } } private  TypeDecoder(); }
TypeDecoder { public static ValueHolder decode(Type<?> type, String text) { try { return type.decode(text != null ? text.trim() : null); } catch (RuntimeException exception) { throw new TypeDecodingException(exception, text, 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 decode(Type<?> type, String text) { try { return type.decode(text != null ? text.trim() : null); } catch (RuntimeException exception) { throw new TypeDecodingException(exception, text, 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);  }