semi-auto cleanup

This commit is contained in:
gnembon committed 2023-02-04 13:26:21 +01:00
1 parent cad80f82c6
commit 8f61271606
99 files changed
+11463 -8007

No files matched your search

@@ -58,7 +58,7 @@ public final class OutputConverter<T>
private final Function<T, LazyValue> converter;
private OutputConverter(Function<T, LazyValue> converter)
private OutputConverter(final Function<T, LazyValue> converter)
{
this.converter = converter;
}
@@ -75,7 +75,9 @@ public final class OutputConverter<T>
public static <T> OutputConverter<T> get(Class<T> returnType)
{
if (Value.class.isAssignableFrom(returnType))
{
return (OutputConverter<T>) VALUE;
}
returnType = (Class<T>) ClassUtils.primitiveToWrapper(returnType); // wrapper holds same generic as primitive: wrapped
return (OutputConverter<T>) Objects.requireNonNull(byResult.get(returnType),
"Unregistered output type: " + returnType + ". Register in OutputConverter");
@@ -89,7 +91,7 @@ public final class OutputConverter<T>
* @param input The value to convert
* @return The converted value
*/
public LazyValue convert(T input)
public LazyValue convert(final T input)
{
return input == null ? LazyValue.NULL : converter.apply(input);
}
@@ -102,11 +104,13 @@ public final class OutputConverter<T>
* @param inputType The class of T
* @param converter The function that converts the an instance of T to a {@link LazyValue}
*/
public static <T> void register(Class<T> inputType, Function<T, LazyValue> converter)
public static <T> void register(final Class<T> inputType, final Function<T, LazyValue> converter)
{
OutputConverter<T> instance = new OutputConverter<T>(converter);
final OutputConverter<T> instance = new OutputConverter<>(converter);
if (byResult.containsKey(inputType))
{
throw new IllegalArgumentException(inputType + " already has a registered OutputConverter");
}
byResult.put(inputType, instance);
}
@@ -119,11 +123,13 @@ public final class OutputConverter<T>
* @param inputType The class of T
* @param converter The function that converts an instance of T to a {@link Value}
*/
public static <T> void registerToValue(Class<T> inputType, Function<T, Value> converter)
public static <T> void registerToValue(final Class<T> inputType, final Function<T, Value> converter)
{
OutputConverter<T> instance = new OutputConverter<>(converter.andThen(v -> (c, t) -> v));
final OutputConverter<T> instance = new OutputConverter<>(converter.andThen(v -> (c, t) -> v));
if (byResult.containsKey(inputType))
{
throw new IllegalArgumentException(inputType + " already has a registered OutputConverter");
}
byResult.put(inputType, instance);
}
}