public abstract class AbstractComposableFunctionRegistry extends Object implements FunctionRegistry, FunctionInspector, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.EnvironmentAware
FunctionRegistry which supports function composition
during lookups. For example if this registry contains function 'a' and 'b' you can
compose them into a single function by simply piping two names together during the
lookup this.lookup(Function.class, "a|b").
Comma ',' is also supported as composition delimiter (e.g., "a,b").| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.context.ApplicationEventPublisher |
applicationEventPublisher |
| Constructor and Description |
|---|
AbstractComposableFunctionRegistry() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addFunction(String name,
Function<?,?> function) |
protected void |
addName(Object function,
String name) |
protected void |
addSupplier(String name,
Supplier<?> supplier) |
protected void |
addType(String name,
FunctionType functionType) |
protected FunctionType |
findType(FunctionRegistration<?> functionRegistration,
String name) |
Set<String> |
getFunctionNames()
Returns the names of available Functions.
|
FunctionType |
getFunctionType(String name) |
Set<String> |
getNames(Class<?> type) |
FunctionRegistration<?> |
getRegistration(Object function) |
Set<String> |
getSupplierNames()
Returns the names of available Suppliers.
|
boolean |
hasFunctions() |
boolean |
hasSuppliers() |
<T> T |
lookup(Class<?> type,
String name)
Will look up the instance of the functional interface by name and type which
can only be Supplier, Consumer or Function.
|
String |
lookupFunctionName(Object function)
A reverse lookup where one can determine the actual name of the function reference.
|
protected void |
register(FunctionRegistration<?> registration,
String key)
Registers function wrapped by the provided FunctionRegistration with
this FunctionRegistry.
|
<T> void |
register(FunctionRegistration<T> functionRegistration) |
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) |
void |
setEnvironment(org.springframework.core.env.Environment environment) |
int |
size()
The size of this catalog, which is the count of all Suppliers,
Function and Consumers currently registered.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitlookup, lookupgetInputType, getInputWrapper, getName, getOutputType, getOutputWrapper, isMessageprotected org.springframework.context.ApplicationEventPublisher applicationEventPublisher
public <T> T lookup(Class<?> type, String name)
FunctionCataloglookup in interface FunctionCatalogT - instance typetype - the type of functional interface. Can be nullname - the definition of the functional interface. Must
not be null;public Set<String> getNames(Class<?> type)
getNames in interface FunctionCatalogpublic boolean hasSuppliers()
public boolean hasFunctions()
public int size()
size in interface FunctionCatalogpublic FunctionType getFunctionType(String name)
public String lookupFunctionName(Object function)
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAwarepublic void setEnvironment(org.springframework.core.env.Environment environment)
setEnvironment in interface org.springframework.context.EnvironmentAwarepublic FunctionRegistration<?> getRegistration(Object function)
getRegistration in interface FunctionInspectorpublic <T> void register(FunctionRegistration<T> functionRegistration)
register in interface FunctionRegistryprotected void register(FunctionRegistration<?> registration, String key)
registration - instance of FunctionRegistrationkey - the name of the functionprotected FunctionType findType(FunctionRegistration<?> functionRegistration, String name)
protected void addType(String name, FunctionType functionType)
Copyright © 2021 Pivotal Software, Inc.. All rights reserved.