Skip to content

Commit

Permalink
cleanup, minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Luigi R. Viggiano committed Jun 6, 2020
1 parent 1f89055 commit 8fb78ea
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions owner/src/main/java/org/aeonbits/owner/Converters.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,17 @@ Object tryConvert(Method targetMethod, Class<?> targetType, String text) {
},

PROPERTY_EDITOR {
private final boolean isPropertyEditorAvailable =
isClassAvailable("java.beans.PropertyEditorManager");

private final boolean isPropertyEditorDisabled =
getBoolean("org.aeonbits.owner.property.editor.disabled");

private final boolean canUsePropertyEditors = isPropertyEditorAvailable && !isPropertyEditorDisabled;

@Override
Object tryConvert(Method targetMethod, Class<?> targetType, String text) {
if (!canUsePropertyEditors())
if (!canUsePropertyEditors)
return SKIP;

PropertyEditor editor = findEditor(targetType);
Expand All @@ -153,10 +161,6 @@ Object tryConvert(Method targetMethod, Class<?> targetType, String text) {
throw unsupportedConversion(e, targetType, text);
}
}

private boolean canUsePropertyEditors() {
return isPropertyEditorAvailable && !isPropertyEditorDisabled;
}
},

/*
Expand Down Expand Up @@ -242,7 +246,8 @@ Object tryConvert(Method targetMethod, Class<?> targetType, String text) {
}
};

private static Object convertWithConverterClass(Method targetMethod, String text, Class<? extends Converter> converterClass) {
private static Object convertWithConverterClass(
Method targetMethod, String text, Class<? extends Converter> converterClass) {
Converter<?> converter;
try {
converter = converterClass.newInstance();
Expand All @@ -260,12 +265,6 @@ private static Object convertWithConverterClass(Method targetMethod, String text

private static final Map<Class<?>, Class<? extends Converter<?>>> converterRegistry =
new ConcurrentHashMap<Class<?>, Class<? extends Converter<?>>>();

private static final boolean isPropertyEditorAvailable =
isClassAvailable("java.beans.PropertyEditorManager");

private static final boolean isPropertyEditorDisabled =
getBoolean("org.aeonbits.owner.property.editor.disabled");

abstract Object tryConvert(Method targetMethod, Class<?> targetType, String text);

Expand All @@ -290,7 +289,8 @@ private static ConversionResult doConvert(Method targetMethod, Class<?> targetTy
return unreachableButCompilerNeedsThis();
}

private static UnsupportedOperationException unsupportedConversion(Exception cause, Class<?> targetType, String text) {
private static UnsupportedOperationException unsupportedConversion(
Exception cause, Class<?> targetType, String text) {
return unsupported(cause, CANNOT_CONVERT_MESSAGE, text, targetType.getCanonicalName());
}

Expand Down

0 comments on commit 8fb78ea

Please sign in to comment.