public abstract class AbstractGenericContextProxy extends Object implements GenericContext
GenericContext interface
that delegates to another instance.| Constructor and Description |
|---|
AbstractGenericContextProxy()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
MutableGenericContext |
createChildContext()
This method creates a new context that inherits all variables from this context (and its parent
contexts).
|
protected abstract GenericContext |
getContext()
This method gets the delegate instance this proxy points to.
|
<T> T |
getVariable(Class<T> type)
This method gets the variable associated with the given
type. |
Object |
getVariable(String variableName)
This method gets the variable associated with the given
variableName. |
<T> T |
getVariable(String variableName,
Class<T> type)
This method gets the variable associated with the given
variableName as the given
type. |
Set<String> |
getVariableNames()
This method returns the names of all defined variables.
|
boolean |
hasVariable(String variableName)
This method determines if the
variable for the given
variableName exists. |
<T> T |
requireVariable(Class<T> type)
This method gets the variable associated with the given
type. |
Object |
requireVariable(String variableName)
This method gets the variable associated with the given
variableName. |
<T> T |
requireVariable(String variableName,
Class<T> type)
This method gets the variable associated with the given
variableName. |
Map<String,Object> |
toMap()
This method allows to create a
Map representing the variables of this context. |
public AbstractGenericContextProxy()
protected abstract GenericContext getContext()
public Object requireVariable(String variableName) throws ValueNotSetException
variableName.requireVariable in interface GenericContextvariableName - is the name of the requested variable.ValueNotSetException - if the requested variable is NOT set.public <T> T requireVariable(String variableName, Class<T> type) throws ValueNotSetException
variableName.requireVariable in interface GenericContextT - the generic type of the variable.variableName - is the name of the requested variable.type - is the class reflecting the type of the variable.ValueNotSetException - if the requested variable is NOT set.public <T> T requireVariable(Class<T> type) throws ValueNotSetException
type. It will use the
classname as variable-name. String or
Integer are bad candidates while MySpecificSingletonComponentInterface might be a
good option.requireVariable in interface GenericContextT - the generic type of the variable.type - is the class reflecting the type of the variable.ValueNotSetException - if the requested variable is NOT set.MutableGenericContext.setVariable(String, Object)public Object getVariable(String variableName)
variableName.getVariable in interface GenericContextvariableName - is the name of the requested variable.null if the variable is NOT set.public <T> T getVariable(String variableName, Class<T> type)
variableName as the given
type. If the type does NOT match the actual type of the variable it may
automatically be converted as possible.getVariable in interface GenericContextT - the generic type of the variable.variableName - is the name of the requested variable.type - is the class reflecting the type of the variable.null if the variable is NOT set.public <T> T getVariable(Class<T> type)
type. It will use the
classname as variable-name. String or
Integer are bad candidates while MySpecificSingletonComponentInterface might be a
good option.getVariable in interface GenericContextT - the generic type of the variable.type - is the class reflecting the type of the variable.null if the variable is NOT set.MutableGenericContext.setVariable(String, Object)public boolean hasVariable(String variableName)
variable for the given
variableName exists.hasVariable in interface GenericContextvariableName - is the name of the requested variable.true if a value exists for the given variableName, false
otherwise.public Set<String> getVariableNames()
GenericContext.hasVariable(String) where possible.getVariableNames in interface GenericContextpublic MutableGenericContext createChildContext()
createChildContext in interface GenericContextpublic Map<String,Object> toMap()
Map representing the variables of this context. This can be useful
to pass this context to an external component (e.g. a template-engine) that typically accepts a
Map. Map will NOT reflect changes of this context and vice versa.toMap in interface GenericContextCopyright © 2001–2015 mmm-Team. All rights reserved.