public interface ILookupDecorator
ILookup,
IContextLookupChainLink| Modifier and Type | Method and Description |
|---|---|
default <TContext,TResult> |
add(Class<TContext> contextType,
Class<TResult> resultType,
BiFunction<TContext,TResult,TResult> wrapperFactory)
Adds a lookup implementation for a given type using a
BiFunction. |
default <TContext,TResult> |
add(Class<TContext> contextType,
Class<TResult> resultType,
BiFunction<TContext,TResult,TResult> wrapperFactory,
boolean decorateNull)
Adds a lookup implementation for a given type using a
BiFunction. |
default <TContext,TResult> |
add(Class<TContext> contextType,
Class<TResult> resultType,
Function<TContext,TResult> factory)
Adds a lookup implementation for a given type using a
Function. |
default <TContext,TResult> |
add(Class<TContext> contextType,
Class<TResult> resultType,
Function<TContext,TResult> factory,
boolean nullIsFallback)
Adds a lookup implementation for a given type using a
Function. |
default <TContext,TResult> |
addConstant(Class<TContext> contextType,
Class<TResult> resultType,
TResult result)
Add a lookup implementation for a given type that always yields a constant result.
|
void |
addLookup(Class t,
IContextLookupChainLink lookup)
Adds a lookup chain element to the chain of lookups for a given type.
|
boolean |
canDecorate(Class t)
Determines whether this instance can be used to decorate the lookup for a certain type.
|
void |
removeLookup(Class t,
IContextLookupChainLink lookup)
Removes a previously registered lookup chain element from the chain of lookups for a given type.
|
default <TContext,TResult> IContextLookupChainLink add(Class<TContext> contextType, Class<TResult> resultType, BiFunction<TContext,TResult,TResult> wrapperFactory)
BiFunction.
This method is closely related to the #add(Function, boolean) method, however it passes the result of the
remaining chain to the delegate for convenient wrapping of the result. Note that if the implementation does not depend
on the previous result in order to wrap it, it is better to use the Function variant, in order to avoid the
possibly costly evaluation of the remainder of the lookup chain.
TContext - The type of the context subject.TResult - The type of the query, which is a base type or the type of the result.wrapperFactory - The factory delegate that will be used to satisfy queries of type TResultIContextLookupChainLink instance as returned by the addLookup(Class, IContextLookupChainLink) call
or null, if either decorator was null, or it could not decorate the
TContext type.default <TContext,TResult> IContextLookupChainLink add(Class<TContext> contextType, Class<TResult> resultType, BiFunction<TContext,TResult,TResult> wrapperFactory, boolean decorateNull)
BiFunction.
This method is closely related to the #add(Function, boolean) method, however it passes the result of the
remaining chain to the delegate for convenient wrapping of the result. Note that if the implementation does not depend
on the previous result in order to wrap it, it is better to use the Function variant, in order to avoid the
possibly costly evaluation of the remainder of the lookup chain.
TContext - The type of the context subject.TResult - The type of the query, which is a base type or the type of the result.wrapperFactory - The factory delegate that will be used to satisfy queries of type TResultdecorateNull - Whether to actually decorate null results of remainder of the chain. If this is set to false, the wrapperFactory
will never be called with null as the second argument but the result of the query for this chain link will be
the null value.IContextLookupChainLink instance as returned by the addLookup(Class, IContextLookupChainLink) call
or null, if either decorator was null, or it could not decorate the
TContext type.default <TContext,TResult> IContextLookupChainLink add(Class<TContext> contextType, Class<TResult> resultType, Function<TContext,TResult> factory)
Function.TContext - The type of the context subject.TResult - The type of the query, which is a base type or the type of the result.factory - The factory delegate that will be used to satisfy queries of type TResult.IContextLookupChainLink instance as returned by the addLookup(Class, IContextLookupChainLink) call
or null, if either decorator was null, or it could not decorate the
TContext type.default <TContext,TResult> IContextLookupChainLink add(Class<TContext> contextType, Class<TResult> resultType, Function<TContext,TResult> factory, boolean nullIsFallback)
Function.TContext - The type of the context subject.TResult - The type of the query, which is a base type or the type of the result.factory - The factory delegate that will be used to satisfy queries of type TResult.nullIsFallback - Whether to treat null-results of the factory as hints to use the remainder of the chain link or to
actually yield the value as the final result.IContextLookupChainLink instance as returned by the addLookup(Class, IContextLookupChainLink) call
or null, if either decorator was null, or it could not decorate the
TContext type.default <TContext,TResult> IContextLookupChainLink addConstant(Class<TContext> contextType, Class<TResult> resultType, TResult result)
Note that in order to work correctly, the type parameter (TResult) should be specified instead of being inferred
by the compiler, because the parameter is used to compare with the query type in the IContextLookup.lookup(java.lang.Object, Class)
call.
TContext - The type of the context subject.TResult - The type of the query, which is a base type or the type of the result.result - The constant value to yield if the chain is queried for an implementation of type TResult.IContextLookupChainLink instance as returned by the addLookup(Class, IContextLookupChainLink) call
or null, if either decorator was null, or it could not decorate the
TContext type.void addLookup(Class t, IContextLookupChainLink lookup)
The lookup chain is context specific. This method will not generally decorate the lookup of all instances of type
t, but only those that stand in context of this instance. This method will only succeed if canDecorate(Class)
yields true for t.
t - The type to decorate the lookup.lookup - The chain element to add to the lookup of the given type.removeLookup(Class, IContextLookupChainLink),
#add(Function, boolean),
#add(BiFunction, boolean),
#addConstant(java.lang.Object)boolean canDecorate(Class t)
t - The type to decorate the lookup for.void removeLookup(Class t, IContextLookupChainLink lookup)
t - The type to remove the decorator from.lookup - The chain element to remove from the lookup of the given type.addLookup(Class, IContextLookupChainLink)