@Override public Object convert(String source, Class<? extends Object> specificType) { Method valueof = getStaticMethod(specificType, "valueof", String.class); try { if (valueof != null) { valueof.setAccessible(true); return valueof.invoke(null, source); } Constructor<?> cons = getConstructor(specificType, String.class); if (cons != null) { cons.setAccessible(true); return cons.newInstance(source); } } catch (InvocationTargetException e) { logger.debug("StringToObjectConverter exception. Source: {} Target: {}", source, specificType); throw new ConversionException(e.getTargetException()); } catch (Throwable e) { throw new ConversionException(e); } throw new UnsupportedOperationException( "No static valueOf(String.class) method or Constructor(String.class) exists on " + specificType.getName()); }