@Test public void testFromString() throws Exception { assertThat(ConstructorBasedConverter.getIfEligible(Person.class).fromString("wisdom").name).isEqualTo("wisdom"); }
@Override public T fromString(String input) throws IllegalArgumentException { try { return constructor.newInstance(input); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { LoggerFactory.getLogger(this.getClass()) .error("Cannot create an instance of {} from \"{}\"", constructor.getDeclaringClass().getName(), input, e); if (e.getCause() != null) { throw new IllegalArgumentException(e.getCause()); } else { throw new IllegalArgumentException(e); } } }
ConstructorBasedConverter implements ParameterConverter<T> { @Override public T fromString(String input) throws IllegalArgumentException { try { return constructor.newInstance(input); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { LoggerFactory.getLogger(this.getClass()) .error("Cannot create an instance of {} from \"{}\"", constructor.getDeclaringClass().getName(), input, e); if (e.getCause() != null) { throw new IllegalArgumentException(e.getCause()); } else { throw new IllegalArgumentException(e); } } } }
ConstructorBasedConverter implements ParameterConverter<T> { @Override public T fromString(String input) throws IllegalArgumentException { try { return constructor.newInstance(input); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { LoggerFactory.getLogger(this.getClass()) .error("Cannot create an instance of {} from \"{}\"", constructor.getDeclaringClass().getName(), input, e); if (e.getCause() != null) { throw new IllegalArgumentException(e.getCause()); } else { throw new IllegalArgumentException(e); } } } private  ConstructorBasedConverter(Class<T> clazz, Constructor<T> constructor); }
ConstructorBasedConverter implements ParameterConverter<T> { @Override public T fromString(String input) throws IllegalArgumentException { try { return constructor.newInstance(input); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { LoggerFactory.getLogger(this.getClass()) .error("Cannot create an instance of {} from \"{}\"", constructor.getDeclaringClass().getName(), input, e); if (e.getCause() != null) { throw new IllegalArgumentException(e.getCause()); } else { throw new IllegalArgumentException(e); } } } private  ConstructorBasedConverter(Class<T> clazz, Constructor<T> constructor); static ConstructorBasedConverter<T> getIfEligible(Class<T> clazz); @Override T fromString(String input); @Override Class<T> getType(); }
ConstructorBasedConverter implements ParameterConverter<T> { @Override public T fromString(String input) throws IllegalArgumentException { try { return constructor.newInstance(input); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { LoggerFactory.getLogger(this.getClass()) .error("Cannot create an instance of {} from \"{}\"", constructor.getDeclaringClass().getName(), input, e); if (e.getCause() != null) { throw new IllegalArgumentException(e.getCause()); } else { throw new IllegalArgumentException(e); } } } private  ConstructorBasedConverter(Class<T> clazz, Constructor<T> constructor); static ConstructorBasedConverter<T> getIfEligible(Class<T> clazz); @Override T fromString(String input); @Override Class<T> getType();  }