ObjectUtils { public static Object toObject( String value) { return toObject( value, ObjectUtils::toBoolean, ObjectUtils::toNumber, ObjectUtils::toExternalString); } private  ObjectUtils(); static Object toObject( String value); static Object toExternalObject( Object value);  }
@Test public void toObject_whenNull() { String value = null; Object object = ObjectUtils.toObject( value); assertThat( "Null", object, is( (Object) null)); value = "null"; object = ObjectUtils.toObject( value); assertThat( "Null", object, is( (Object) null)); }
@Test public void toObject_whenString() { String value = "This is just a plain old string"; Object object = ObjectUtils.toObject( value); assertThat( "String", object, is( value)); }
@Test public void toObject_whenInteger() { String value = String.valueOf( Integer.MAX_VALUE); Object object = ObjectUtils.toObject( value); assertThat( "Integer", object, is( Integer.MAX_VALUE)); }
@Test public void toObject_whenLong() { String value = String.valueOf( Long.MIN_VALUE); Object object = ObjectUtils.toObject( value); assertThat( "Long", object, is( Long.MIN_VALUE)); }
@Test public void toObject_whenDecimal() { BigDecimal decimal = new BigDecimal( "-42.00"); String value = String.valueOf( decimal); Object object = ObjectUtils.toObject( value); assertThat( "Decimal", object, is( decimal)); }
@Test public void toObject_whenBoolean() { String value = "TRUE"; Object object = ObjectUtils.toObject( value); assertThat( "Boolean", object, is( Boolean.TRUE)); value = "false"; object = ObjectUtils.toObject( value); assertThat( "Boolean", object, is( Boolean.FALSE)); }