BindingConvertor { public static BindingConvertor<String, String> truncatedString( int length ) { return new TruncatedStringBindingConvertor( length ); }  abstract R sourceToTarget( V value ); abstract V targetToSource( R value ); static BindingConvertor<Collection, Object[]> collection2ObjectArray(); static BindingConvertor<Integer, String> integer2String(); static BindingConvertor<Integer, Boolean> integer2Boolean(); static BindingConvertor<String, Integer> string2Integer(); static BindingConvertor<Long, String> long2String(); static BindingConvertor<Date, String> date2String(); static BindingConvertor<Date, String> date2String( final DateFormat format ); static BindingConvertor<String, String> string2String(); static BindingConvertor<Boolean, String> boolean2String(); static BindingConvertor<Double, String> double2String(); static BindingConvertor<String, Double> string2Double(); static BindingConvertor<Object, Boolean> object2Boolean(); static BindingConvertor<String, String> truncatedString( int length );  }
@Test public void testTruncatedString() throws Exception { BindingConvertor<String, String> bc = BindingConvertor.truncatedString( 50 ); String longString = "the quick brown fox jumped over the lazy dog. the quick brown fox jumped over the lazy dog... again."; assertEquals( 53, bc.sourceToTarget( longString ).length() ); }