public interface IContextLookup
ILookup capabilities for a given object.
This is useful in the case where lookup functionality is not intrinsic to an item or where an existing object cannot implement the interface or when an item needs to be decorated externally with new lookup functionality.
ILookup,
IContextLookup| Modifier and Type | Field and Description |
|---|---|
static IContextLookup |
EMPTY_CONTEXT_LOOKUP
An
ILookupContext instance that always returns null. |
| Modifier and Type | Method and Description |
|---|---|
default <T> T |
lookup(Class<T> type,
Object item)
Typesafe convenience method for the
lookup(Object, Class) method. |
static <T> T |
lookup(Class<T> tType,
Object context,
IContextLookup lookup)
Utility method that helps keeping code more clean when using
IContextLookup lookup(Object, Class)
calls. |
static <T> T |
lookup(Class<T> tType,
Object context,
IContextLookup lookup,
T fallback)
Utility method that helps keeping code more clean when using
IContextLookup lookup(Object, Class)
calls. |
Object |
lookup(Object item,
Class type)
Tries to create or retrieve an implementation of the given type for a given item.
|
default <T> T |
safeLookup(Class<T> type,
Object item)
Typesafe convenience method for the
lookup(Object, Class) method. |
static final IContextLookup EMPTY_CONTEXT_LOOKUP
ILookupContext instance that always returns null.default <T> T lookup(Class<T> type, Object item)
lookup(Object, Class) method.T - The type to query, this is passed to the lookup(Object, Class) method using
typeof. The result of the query will be converted to this type.item - The item to pass to the lookup(Object, Class) method.null.static <T> T lookup(Class<T> tType, Object context, IContextLookup lookup)
IContextLookup lookup(Object, Class)
calls.T - The type that is the target of the lookup.context - The context object to pass to the lookup.lookup - The actual lookup provider.lookup which may be null.static <T> T lookup(Class<T> tType, Object context, IContextLookup lookup, T fallback)
IContextLookup lookup(Object, Class)
calls.T - The type that is the target of the lookup.context - The context object to pass to the lookup.lookup - The actual lookup provider.fallback - The fallback value to use if the lookup yields nulllookup or fallback if the former yields null.Object lookup(Object item, Class type)
item - the item to lookup a type fortype - the type to look upnullILookup.lookup(Class)default <T> T safeLookup(Class<T> type, Object item)
lookup(Object, Class) method.NoSuchElementException - If the context lookup did not yield a non-null result for the type.T - The type to query, this is passed to the lookup(Object, Class) method using
typeof. The result of the query will be converted to this type.item - The item to pass to the lookup(Object, Class) method.null.