Package org.eclipse.handly.context
Interface IContext
-
- All Known Implementing Classes:
Context,GuiceContext
public interface IContextA context supplies values associated with keys; keys are instances ofPropertyorClass.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 booleancontainsKey(java.lang.Class<?> clazz)Returns whether this context has a value associated with the given class.booleancontainsKey(Property<?> property)Returns whether this context has a value associated with the given property.<T> Tget(java.lang.Class<T> clazz)Returns the context value associated with the given class.<T> Tget(Property<T> property)Returns the context value associated with the given property.default <T> TgetOrDefault(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:
trueif this context has a value for the given property, andfalseotherwise
-
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:
trueif this context has a value for the given class, andfalseotherwise
-
-