public interface IContextLookupChainLink extends IContextLookup
Implementations will perform the lookup in the IContextLookup.lookup(Object, Class)
method and delegate to the
next implementation in the chain if they cannot satisfy the request.
EMPTY_CONTEXT_LOOKUP
Modifier and Type | Method and Description |
---|---|
static IContextLookupChainLink |
createAddingLookupChainLink(Class type,
Object instance)
Factory method for a lookup chain element that simply adds an entry to a lookup chain.
|
static IContextLookupChainLink |
createAddingLookupChainLink(ILookup lookup)
Factory method for a lookup chain element that adds an
ILookup layer to a lookup chain. |
static IContextLookupChainLink |
createAddingLookupChainLink(Object instance)
Factory method for a lookup chain element that adds an dynamic instance to a lookup chain.
|
static IContextLookupChainLink |
createContextLookupChainLink(IContextLookup callback)
Creates a lookup chain link that is backed by the given callback.
|
static <TContext,TResult> |
createFactoryLookupChainLink(Class<TContext> contextType,
Class<TResult> resultType,
Function<TContext,TResult> factory)
Factory method for a lookup chain element that uses a
Function to yield a TResult for a specific
TContext . |
static IContextLookupChainLink |
createHidingLookupChainLink(Class type)
Factory method for a lookup chain element that removes the entry from the lookup chain for a given type.
|
void |
setNext(IContextLookup next)
This method is called by the framework to register the fallback lookup implementation that should be used during a call
to
IContextLookup.lookup(Object, Class) . |
lookup, lookup, lookup, lookup, safeLookup
static IContextLookupChainLink createAddingLookupChainLink(Class type, Object instance)
type
- The type to add to the lookup.instance
- The instance to return if the type
is being looked up.static IContextLookupChainLink createAddingLookupChainLink(ILookup lookup)
ILookup
layer to a lookup chain.
If the lookup returns null
, the call will be propagated to the chain.
lookup
- The lookup to use.static IContextLookupChainLink createAddingLookupChainLink(Object instance)
The instance returned will check whether instance
is of the queried type and will then return the instance.
instance
- The instance to query the type from dynamically.static IContextLookupChainLink createContextLookupChainLink(IContextLookup callback)
If the callback returns null
the request is passed to the chain.
callback
- The callback to invoke.static <TContext,TResult> IContextLookupChainLink createFactoryLookupChainLink(Class<TContext> contextType, Class<TResult> resultType, Function<TContext,TResult> factory)
Function
to yield a TResult
for a specific
TContext
.
If the resulting link is queried
for TResult
and the context is of
type TContext
, the factory
method will be queried and the result will be returned. Otherwise the next
chain link will be delegated the request to.
factory
- The factory delegate to use that yields the result for a given context.static IContextLookupChainLink createHidingLookupChainLink(Class type)
type
- The type to hide from the lookup.void setNext(IContextLookup next)
IContextLookup.lookup(Object, Class)
.
If the implementation cannot satisfy the query, it will use the provided context as a fallback. Note that implementations can also use the results returned by the next lookup and decorate it appropriately.
next
- The context to use as a fallback.