diff --git a/convert/impl/src/main/java/org/jboss/forge/convert/impl/ConverterFactoryImpl.java b/convert/impl/src/main/java/org/jboss/forge/convert/impl/ConverterFactoryImpl.java index bed4537bf6..67a4aaed38 100644 --- a/convert/impl/src/main/java/org/jboss/forge/convert/impl/ConverterFactoryImpl.java +++ b/convert/impl/src/main/java/org/jboss/forge/convert/impl/ConverterFactoryImpl.java @@ -40,30 +40,34 @@ public Converter getConverter(Class source, Class target) break; } } - if (result == null && String.class.equals(target)) - { - result = (Converter) Converters.TO_STRING; - } - if (result == null && target.isAssignableFrom(source)) - { - result = (Converter) Converters.NOOP; - } if (result == null) { - try + if (String.class.equals(target)) { - result = new MethodConverter(source, target, null, target.getMethod("valueOf", source)); + result = (Converter) Converters.TO_STRING; } - catch (NoSuchMethodException noValueOf) + else if (target.isAssignableFrom(source)) + { + result = (Converter) Converters.NOOP; + } + else { try { - result = new ConstructorConverter(source, target, target.getConstructor(source)); + result = new MethodConverter(source, target, null, target.getMethod("valueOf", source)); } - catch (NoSuchMethodException noConstructor) + catch (NoSuchMethodException noValueOf) { - throw new ConverterNotFoundException(source, target); + try + { + result = new ConstructorConverter(source, target, target.getConstructor(source)); + } + catch (NoSuchMethodException noConstructor) + { + throw new ConverterNotFoundException(source, target); + } } + } } return result;