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
GenericContext
variableName
.requireVariable
in interface GenericContext
variableName
- 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
GenericContext
variableName
.requireVariable
in interface GenericContext
T
- 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
GenericContext
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 GenericContext
T
- 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)
GenericContext
variableName
.getVariable
in interface GenericContext
variableName
- is the name of the requested variable.null
if the variable is NOT set.public <T> T getVariable(String variableName, Class<T> type)
GenericContext
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 GenericContext
T
- 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)
GenericContext
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 GenericContext
T
- 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)
GenericContext
variable
for the given variableName
exists.hasVariable
in interface GenericContext
variableName
- is the name of the requested variable.true
if a value exists for the given variableName
, false
otherwise.public Set<String> getVariableNames()
GenericContext
GenericContext.hasVariable(String)
where possible.getVariableNames
in interface GenericContext
public MutableGenericContext createChildContext()
GenericContext
createChildContext
in interface GenericContext
public Map<String,Object> toMap()
GenericContext
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 GenericContext
Copyright © 2001–2016 mmm-Team. All rights reserved.