GH-568 Add support for casting resulting function as Runnable
Resolves #568
This commit is contained in:
@@ -415,7 +415,8 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
|
|||||||
*
|
*
|
||||||
* @author Oleg Zhurakousky
|
* @author Oleg Zhurakousky
|
||||||
*/
|
*/
|
||||||
public class FunctionInvocationWrapper implements Function<Object, Object>, Consumer<Object>, Supplier<Object> {
|
public class FunctionInvocationWrapper implements Function<Object, Object>, Consumer<Object>,
|
||||||
|
Supplier<Object>, Runnable {
|
||||||
|
|
||||||
private final Object target;
|
private final Object target;
|
||||||
|
|
||||||
@@ -519,6 +520,11 @@ public class SimpleFunctionRegistry implements FunctionRegistry, FunctionInspect
|
|||||||
return this.doApply(input, false, enricher);
|
return this.doApply(input, false, enricher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
this.apply(null);
|
||||||
|
}
|
||||||
|
|
||||||
public Type getFunctionType() {
|
public Type getFunctionType() {
|
||||||
return this.functionType;
|
return this.functionType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -484,6 +484,13 @@ public class BeanFactoryAwareFunctionRegistryTests {
|
|||||||
assertThat(f.apply("Bubbles")).isEqualTo("BUBBLES");
|
assertThat(f.apply("Bubbles")).isEqualTo("BUBBLES");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSupplierConsumerAsRunnable() {
|
||||||
|
FunctionCatalog catalog = this.configureCatalog(SampleFunctionConfiguration.class);
|
||||||
|
Runnable f = catalog.lookup("numberword|imperativeConsumer");
|
||||||
|
f.run();
|
||||||
|
}
|
||||||
|
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
public static class PojoToMessageFunctionCompositionConfiguration {
|
public static class PojoToMessageFunctionCompositionConfiguration {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user