Interface ModelContributable
-
- All Known Subinterfaces:
HstMutableRequestContext
,HstRequest
,HstRequestContext
public interface ModelContributable
Interface for abstraction that allows to contribute, retrieve and remove model objects.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
getModel(String name)
Returns the model object associated with the givenname
, ornull
if no model object of the givenname
exists.Iterable<String>
getModelNames()
Returns an unmodifiableIterable
containing the names of the model objects available to this.Map<String,Object>
getModelsMap()
Returns an unmodifiable map of model objects contributed bysetModel(String, Object)
.void
removeModel(String name)
Removes a model object from this.Object
setModel(String name, Object model)
Stores a model object in this.
-
-
-
Method Detail
-
getModel
<T> T getModel(String name)
Returns the model object associated with the givenname
, ornull
if no model object of the givenname
exists.- Parameters:
name
- the name of the model object- Returns:
- the model object associated with the
name
, or null if the model object does not exist.
-
getModelNames
Iterable<String> getModelNames()
Returns an unmodifiableIterable
containing the names of the model objects available to this. This method returns an emptyIterable
if this has no model object available to it.- Returns:
- an
Iterable
of strings containing the names of model objects of this.
-
getModelsMap
Map<String,Object> getModelsMap()
Returns an unmodifiable map of model objects contributed bysetModel(String, Object)
.Note that the returned map contains only the pairs of model name and value objects contributed by
setModel(String, Object)
, but it does not contain attributes set by#setAttribute(String,Object)
API calls, whereas most implementations of this interface (such asHstRequest
andHstRequestContext
) provides a combined view for bothmodels
and otherattributes
through#getAttribute(String)
,#getAttributeNames()
or#getAttributeMap
.- Returns:
- an unmodifiable map of model objects contributed by
setModel(String, Object)
-
setModel
Object setModel(String name, Object model)
Stores a model object in this.Model objects are contributed by a controller component to this, in general. And, the contributed model objects may be accessed in view rendering or special model aggregation / serialization request pipeline processing.
If the model object passed in is null, the effect is the same as calling
removeModel(java.lang.String)
.- Parameters:
name
- the name of the model objectmodel
- the model object to be stored- Returns:
- the previous model object associated with name, or null if there was no mapping for name.
-
removeModel
void removeModel(String name)
Removes a model object from this.- Parameters:
name
- aString
specifying the name of the model object to remove
-
-