Package org.eclipse.handly.context
Interface IContext
-
- All Known Implementing Classes:
Context
,GuiceContext
public interface IContext
A context supplies values associated with keys; keys are instances ofProperty
orClass
.Context implementations may use an identity-based lookup, name-based lookup, or anything in-between. For portability, keys need to be unique instances with unique names.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
containsKey(java.lang.Class<?> clazz)
Returns whether this context has a value associated with the given class.boolean
containsKey(Property<?> property)
Returns whether this context has a value associated with the given property.<T> T
get(java.lang.Class<T> clazz)
Returns the context value associated with the given class.<T> T
get(Property<T> property)
Returns the context value associated with the given property.default <T> T
getOrDefault(Property<T> property)
Returns the context value associated with the given property; if no value is associated with the given property, returns the default value of the property.
-
-
-
Method Detail
-
get
<T> T get(Property<T> property)
Returns the context value associated with the given property.- Parameters:
property
- the property being queried (notnull
)- Returns:
- an object corresponding to the given property, or
null
-
getOrDefault
default <T> T getOrDefault(Property<T> property)
Returns the context value associated with the given property; if no value is associated with the given property, returns the default value of the property.This implementation makes no guarantees about synchronization or atomicity.
- Parameters:
property
- the property being queried (notnull
)- Returns:
- an object corresponding to the given property, or the property's
default value (may be
null
) - See Also:
Property.defaultValue()
-
get
<T> T get(java.lang.Class<T> clazz)
Returns the context value associated with the given class.- Parameters:
clazz
- the class being queried (notnull
)- Returns:
- an object corresponding to the given class, or
null
-
containsKey
boolean containsKey(Property<?> property)
Returns whether this context has a value associated with the given property.- Parameters:
property
- the property being queried (notnull
)- Returns:
true
if this context has a value for the given property, andfalse
otherwise
-
containsKey
boolean containsKey(java.lang.Class<?> clazz)
Returns whether this context has a value associated with the given class.- Parameters:
clazz
- the class being queried (notnull
)- Returns:
true
if this context has a value for the given class, andfalse
otherwise
-
-