Fix FunctionTypeUtils outout type logic for Supplier

This commit is contained in:
Oleg Zhurakousky
2021-10-26 12:01:35 +02:00
parent 40fe70d44c
commit 27734c7f6e
2 changed files with 25 additions and 5 deletions

View File

@@ -281,18 +281,18 @@ public final class FunctionTypeUtils {
logger.debug("Consumer does not have output type, returning null as output type.");
return null;
}
Type inputType;
Type outputType;
if (functionType instanceof Class) {
functionType = Function.class.isAssignableFrom((Class<?>) functionType)
? TypeResolver.reify(Function.class, (Class<Function<?, ?>>) functionType)
: TypeResolver.reify(Function.class, (Class<Supplier<?>>) functionType);
: TypeResolver.reify(Supplier.class, (Class<Supplier<?>>) functionType);
}
inputType = functionType instanceof ParameterizedType
outputType = functionType instanceof ParameterizedType
? (isSupplier(functionType) ? ((ParameterizedType) functionType).getActualTypeArguments()[0] : ((ParameterizedType) functionType).getActualTypeArguments()[1])
: Object.class;
return inputType;
return outputType;
}
public static Type getImmediateGenericType(Type type, int index) {