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, wait
lookup, lookup
getInputType, getInputWrapper, getName, getOutputType, getOutputWrapper, isMessage
protected org.springframework.context.ApplicationEventPublisher applicationEventPublisher
public <T> T lookup(Class<?> type, String name)
FunctionCatalog
lookup
in interface FunctionCatalog
T
- 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 FunctionCatalog
public boolean hasSuppliers()
public boolean hasFunctions()
public int size()
size
in interface FunctionCatalog
public FunctionType getFunctionType(String name)
public String lookupFunctionName(Object function)
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface org.springframework.context.ApplicationEventPublisherAware
public void setEnvironment(org.springframework.core.env.Environment environment)
setEnvironment
in interface org.springframework.context.EnvironmentAware
public FunctionRegistration<?> getRegistration(Object function)
getRegistration
in interface FunctionInspector
public <T> void register(FunctionRegistration<T> functionRegistration)
register
in interface FunctionRegistry
protected void register(FunctionRegistration<?> registration, String key)
registration
- instance of FunctionRegistration
key
- the name of the functionprotected FunctionType findType(FunctionRegistration<?> functionRegistration, String name)
protected void addType(String name, FunctionType functionType)
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.