Class ModelMap
- All Implemented Interfaces:
- Serializable, Cloneable, Map<String,- Object>, SequencedMap<String, - Object> 
- Direct Known Subclasses:
- ExtendedModelMap, RedirectAttributesModelMap
Implementation of 
Map for use when building model data for use
with UI tools. Supports chained calls and generation of model attribute names.
This class serves as generic model holder for Servlet MVC but is not tied to it.
Check out the Model interface for an interface variant.
- Since:
- 2.0
- Author:
- Rob Harrop, Juergen Hoeller
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class AbstractMapAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> 
- 
Constructor SummaryConstructorsConstructorDescriptionModelMap()Construct a new, emptyModelMap.Construct a newModelMapcontaining the supplied attribute.Construct a newModelMapcontaining the supplied attribute under the supplied name.
- 
Method SummaryModifier and TypeMethodDescriptionaddAllAttributes(@Nullable Collection<?> attributeValues) Copy all attributes in the suppliedCollectioninto thisMap, using attribute name generation for each element.addAllAttributes(@Nullable Map<String, ?> attributes) Copy all attributes in the suppliedMapinto thisMap.addAttribute(Object attributeValue) Add the supplied attribute to thisMapusing agenerated name.addAttribute(String attributeName, @Nullable Object attributeValue) Add the supplied attribute under the supplied name.booleancontainsAttribute(String attributeName) Does this model contain an attribute of the given name?getAttribute(String attributeName) Return the attribute value for the given name, if any.mergeAttributes(@Nullable Map<String, ?> attributes) Copy all attributes in the suppliedMapinto thisMap, with existing objects of the same name taking precedence (i.e.Methods inherited from class LinkedHashMapclear, containsValue, entrySet, forEach, get, getOrDefault, keySet, newLinkedHashMap, putFirst, putLast, removeEldestEntry, replaceAll, reversed, sequencedEntrySet, sequencedKeySet, sequencedValues, valuesMethods inherited from class HashMapclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from class AbstractMapequals, hashCode, toStringMethods inherited from interface Mapcompute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, sizeMethods inherited from interface SequencedMapfirstEntry, lastEntry, pollFirstEntry, pollLastEntry
- 
Constructor Details- 
ModelMappublic ModelMap()Construct a new, emptyModelMap.
- 
ModelMap
- 
ModelMapConstruct a newModelMapcontaining the supplied attribute. Uses attribute name generation to generate the key for the supplied model object.- See Also:
 
 
- 
- 
Method Details- 
addAttribute
- 
addAttributeAdd the supplied attribute to thisMapusing agenerated name.Note: Empty Collectionsare not added to the model when using this method because we cannot correctly determine the true convention name. View code should check fornullrather than for empty collections as is already done by JSTL tags.- Parameters:
- attributeValue- the model attribute value (never- null)
 
- 
addAllAttributesCopy all attributes in the suppliedCollectioninto thisMap, using attribute name generation for each element.- See Also:
 
- 
addAllAttributes
- 
mergeAttributes
- 
containsAttributeDoes this model contain an attribute of the given name?- Parameters:
- attributeName- the name of the model attribute (never- null)
- Returns:
- whether this model contains a corresponding attribute
 
- 
getAttribute
 
-