public abstract class AbstractContext extends 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(String key)
Searches for the key in this context and its hierarchy.
|
protected <T> T |
convertValue(Object value,
Class<T> type) |
void |
destroy()
Destroys this context.
|
protected abstract Object |
doGet(String key) |
Object |
get(String key)
Returns the value associated with the given key.
|
<T> T |
get(String key,
T defaultValue)
Returns the value associated with the given key.
|
<T> T |
getAs(String key)
/**
Finds a value associated with the given key.
|
<T> T |
getAs(String key,
T defaultValue)
Finds a value associated with the given key.
|
boolean |
getAsBoolean(String key)
Finds a value associated with the given key.
|
boolean |
getAsBoolean(String key,
boolean defaultValue)
Finds a value associated with the given key.
|
double |
getAsDouble(String key)
Finds a value associated with the given key.
|
double |
getAsDouble(String key,
double defaultValue)
Finds a value associated with the given key.
|
float |
getAsFloat(String key)
Finds a value associated with the given key.
|
float |
getAsFloat(String key,
float defaultValue)
Finds a value associated with the given key.
|
int |
getAsInt(String key)
Finds a value associated with the given key.
|
int |
getAsInt(String key,
int defaultValue)
Finds a value associated with the given key.
|
long |
getAsLong(String key)
Finds a value associated with the given key.
|
long |
getAsLong(String key,
long defaultValue)
Finds a value associated with the given key.
|
String |
getAsString(String key)
Finds a value associated with the given key.
|
String |
getAsString(String key,
String defaultValue)
Finds a value associated with the given key.
|
Object |
getAt(String key)
Returns the value associated with the given key.
|
<T> T |
getAt(String key,
T defaultValue)
Returns the value associated with the given key.
|
<T> T |
getConverted(String key,
Class<T> type)
/**
Finds a value associated with the given key.
|
<T> T |
getConverted(String key,
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.Contextal . |
protected Context parentContext
@Nullable public Context getParentContext()
Context
Context
if it exists.getParentContext
in interface Context
@Nullable public <T> T get(@Nonnull String key, @Nullable T defaultValue)
Context
@Nullable public Object getAt(@Nonnull String key)
Context
@Nullable public <T> T getAt(@Nonnull String key, @Nullable T defaultValue)
Context
@Nullable public Object get(@Nonnull String key)
Context
public void destroy()
Context
public boolean containsKey(@Nonnull String key)
Context
containsKey
in interface Context
key
- the key to searchpublic boolean getAsBoolean(@Nonnull String key)
Context
getAsBoolean
in interface Context
key
- the key to searchpublic boolean getAsBoolean(@Nonnull 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 String key)
Context
public int getAsInt(@Nonnull String key, int defaultValue)
Context
public long getAsLong(@Nonnull String key)
Context
public long getAsLong(@Nonnull String key, long defaultValue)
Context
public float getAsFloat(@Nonnull String key)
Context
getAsFloat
in interface Context
key
- the key to searchpublic float getAsFloat(@Nonnull 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 String key)
Context
getAsDouble
in interface Context
key
- the key to searchpublic double getAsDouble(@Nonnull 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 String getAsString(@Nonnull String key)
Context
getAsString
in interface Context
key
- the key to search@Nullable public String getAsString(@Nonnull String key, @Nullable 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 String key)
Context
@Nullable public <T> T getAs(@Nonnull String key, @Nullable T defaultValue)
Context
@Nullable public <T> T getConverted(@Nonnull String key, @Nonnull 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 String key, @Nonnull 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 found@Nonnull public <T> T injectMembers(@Nonnull T instance)
Context
griffon.inject.Contextal
.injectMembers
in interface Context
T
- the type of the instanceinstance
- the instance on which contextual members will be injected.