public abstract class AbstractContext extends java.lang.Object implements Context
Modifier and Type | Field and Description |
---|---|
protected Context |
parentContext |
Constructor and Description |
---|
AbstractContext(Context parentContext) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.String key)
Searches for the key in this context and its hierarchy.
|
protected <T> T |
convertValue(java.lang.Object value,
java.lang.Class<T> type) |
void |
destroy()
Destroys this context.
|
protected abstract java.lang.Object |
doGet(java.lang.String key) |
java.lang.Object |
get(java.lang.String key)
Returns the value associated with the given key.
|
<T> T |
get(java.lang.String key,
T defaultValue)
Returns the value associated with the given key.
|
<T> T |
getAs(java.lang.String key)
/**
Finds a value associated with the given key.
|
<T> T |
getAs(java.lang.String key,
T defaultValue)
Finds a value associated with the given key.
|
boolean |
getAsBoolean(java.lang.String key)
Finds a value associated with the given key.
|
boolean |
getAsBoolean(java.lang.String key,
boolean defaultValue)
Finds a value associated with the given key.
|
double |
getAsDouble(java.lang.String key)
Finds a value associated with the given key.
|
double |
getAsDouble(java.lang.String key,
double defaultValue)
Finds a value associated with the given key.
|
float |
getAsFloat(java.lang.String key)
Finds a value associated with the given key.
|
float |
getAsFloat(java.lang.String key,
float defaultValue)
Finds a value associated with the given key.
|
int |
getAsInt(java.lang.String key)
Finds a value associated with the given key.
|
int |
getAsInt(java.lang.String key,
int defaultValue)
Finds a value associated with the given key.
|
long |
getAsLong(java.lang.String key)
Finds a value associated with the given key.
|
long |
getAsLong(java.lang.String key,
long defaultValue)
Finds a value associated with the given key.
|
java.lang.String |
getAsString(java.lang.String key)
Finds a value associated with the given key.
|
java.lang.String |
getAsString(java.lang.String key,
java.lang.String defaultValue)
Finds a value associated with the given key.
|
java.lang.Object |
getAt(java.lang.String key)
Returns the value associated with the given key.
|
<T> T |
getAt(java.lang.String key,
T defaultValue)
Returns the value associated with the given key.
|
<T> T |
getConverted(java.lang.String key,
java.lang.Class<T> type)
/**
Finds a value associated with the given key.
|
<T> T |
getConverted(java.lang.String key,
java.lang.Class<T> type,
T defaultValue)
Finds a value associated with the given key.
|
Context |
getParentContext()
Returns the parent
Context if it exists. |
<T> T |
injectMembers(T instance)
Inject properties and members annotated with
griffon.inject.Contextual . |
protected Context parentContext
public AbstractContext(@Nullable Context parentContext)
@Nullable public Context getParentContext()
Context
Context
if it exists.getParentContext
in interface Context
@Nullable public <T> T get(@Nonnull java.lang.String key, @Nullable T defaultValue)
Context
@Nullable public java.lang.Object getAt(@Nonnull java.lang.String key)
Context
@Nullable public <T> T getAt(@Nonnull java.lang.String key, @Nullable T defaultValue)
Context
@Nullable public java.lang.Object get(@Nonnull java.lang.String key)
Context
public void destroy()
Context
public boolean containsKey(@Nonnull java.lang.String key)
Context
containsKey
in interface Context
key
- the key to search@Nullable protected abstract java.lang.Object doGet(@Nonnull java.lang.String key)
public boolean getAsBoolean(@Nonnull java.lang.String key)
Context
getAsBoolean
in interface Context
key
- the key to searchpublic boolean getAsBoolean(@Nonnull java.lang.String key, boolean defaultValue)
Context
getAsBoolean
in interface Context
key
- the key to searchdefaultValue
- the value to be returned if the key is not foundpublic int getAsInt(@Nonnull java.lang.String key)
Context
public int getAsInt(@Nonnull java.lang.String key, int defaultValue)
Context
public long getAsLong(@Nonnull java.lang.String key)
Context
public long getAsLong(@Nonnull java.lang.String key, long defaultValue)
Context
public float getAsFloat(@Nonnull java.lang.String key)
Context
getAsFloat
in interface Context
key
- the key to searchpublic float getAsFloat(@Nonnull java.lang.String key, float defaultValue)
Context
getAsFloat
in interface Context
key
- the key to searchdefaultValue
- the value to be returned if the key is not foundpublic double getAsDouble(@Nonnull java.lang.String key)
Context
getAsDouble
in interface Context
key
- the key to searchpublic double getAsDouble(@Nonnull java.lang.String key, double defaultValue)
Context
getAsDouble
in interface Context
key
- the key to searchdefaultValue
- the value to be returned if the key is not found@Nullable public java.lang.String getAsString(@Nonnull java.lang.String key)
Context
getAsString
in interface Context
key
- the key to search@Nullable public java.lang.String getAsString(@Nonnull java.lang.String key, @Nullable java.lang.String defaultValue)
Context
getAsString
in interface Context
key
- the key to searchdefaultValue
- the value to be returned if the key is not found@Nullable public <T> T getAs(@Nonnull java.lang.String key)
Context
@Nullable public <T> T getAs(@Nonnull java.lang.String key, @Nullable T defaultValue)
Context
@Nullable public <T> T getConverted(@Nonnull java.lang.String key, @Nonnull java.lang.Class<T> type)
Context
PropertyEditor
.getConverted
in interface Context
key
- the key to searchtype
- the type to be returned@Nullable public <T> T getConverted(@Nonnull java.lang.String key, @Nonnull java.lang.Class<T> type, @Nullable T defaultValue)
Context
PropertyEditor
.
If not found then the supplied defaultValue will be returned.getConverted
in interface Context
key
- the key to searchtype
- the type to be returneddefaultValue
- the value to be returned if the key is not foundprotected <T> T convertValue(@Nullable java.lang.Object value, @Nonnull java.lang.Class<T> type)
@Nonnull public <T> T injectMembers(@Nonnull T instance)
Context
griffon.inject.Contextual
.injectMembers
in interface Context
T
- the type of the instanceinstance
- the instance on which contextual members will be injected.