FunctionUtils polishing
- attempted to make code more functional (eat our own dog food) and concise - addressed PR comment - additional cleanup/polishing of FunctionUtils and related classes - Removed Function/Supplier/ConsumerProxy classes by extending type info on their super interface - Renamed FunctionUtils to FunctionFactoryUtils - Added javadoc to FunctionFactoryUtils to explain its design considerations as well as what it can and can not doi Fixes gh-90
This commit is contained in:
committed by
Dave Syer
parent
2644ab3178
commit
a973b678f1
@@ -52,7 +52,7 @@ import org.springframework.cloud.function.support.FluxConsumer;
|
||||
import org.springframework.cloud.function.support.FluxFunction;
|
||||
import org.springframework.cloud.function.support.FluxSupplier;
|
||||
import org.springframework.cloud.function.support.FunctionFactoryMetadata;
|
||||
import org.springframework.cloud.function.support.FunctionUtils;
|
||||
import org.springframework.cloud.function.support.FunctionFactoryUtils;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.ResolvableType;
|
||||
@@ -297,17 +297,17 @@ public class ContextFunctionCatalogAutoConfiguration {
|
||||
|
||||
private boolean isFluxFunction(String name, Function<?, ?> function) {
|
||||
boolean fluxTypes = this.hasFluxTypes(function);
|
||||
return fluxTypes || FunctionUtils.isFluxFunction(function);
|
||||
return fluxTypes || FunctionFactoryUtils.isFluxFunction(function);
|
||||
}
|
||||
|
||||
private boolean isFluxConsumer(String name, Consumer<?> consumer) {
|
||||
boolean fluxTypes = this.hasFluxTypes(consumer);
|
||||
return fluxTypes || FunctionUtils.isFluxConsumer(consumer);
|
||||
return fluxTypes || FunctionFactoryUtils.isFluxConsumer(consumer);
|
||||
}
|
||||
|
||||
private boolean isFluxSupplier(String name, Supplier<?> supplier) {
|
||||
boolean fluxTypes = this.hasFluxTypes(supplier);
|
||||
return fluxTypes || FunctionUtils.isFluxSupplier(supplier);
|
||||
return fluxTypes || FunctionFactoryUtils.isFluxSupplier(supplier);
|
||||
}
|
||||
|
||||
private boolean hasFluxTypes(Object function) {
|
||||
@@ -379,7 +379,7 @@ public class ContextFunctionCatalogAutoConfiguration {
|
||||
else if (registry instanceof BeanFactory) {
|
||||
Object bean = ((BeanFactory) registry).getBean(name);
|
||||
if (bean instanceof FunctionFactoryMetadata) {
|
||||
FunctionFactoryMetadata factory = (FunctionFactoryMetadata) bean;
|
||||
FunctionFactoryMetadata<?> factory = (FunctionFactoryMetadata<?>) bean;
|
||||
Type type = factory.getFactoryMethod().getGenericReturnType();
|
||||
param = extractType(type, paramType, index);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user