Top Description Constructors Methods
org.springframework.ui

public Class ConcurrentModel

extends ConcurrentHashMap<String, Object>
implements Model
Class Inheritance
All Implemented Interfaces
org.springframework.ui.Model
Known Direct Subclasses
org.springframework.validation.support.BindingAwareConcurrentModel
Annotations
@SuppressWarnings:serial
Imports
java.util.Collection, .Map, java.util.concurrent.ConcurrentHashMap, org.springframework.core.Conventions, org.springframework.lang.Nullable, org.springframework.util.Assert

Implementation of the Model interface based on a ConcurrentHashMap for use in concurrent scenarios.

Exposed to handler methods by Spring WebFlux, typically via a declaration of the Model interface. There is typically no need to create it within user code. If necessary a handler method can return a regular java.util.Map, likely a java.util.ConcurrentMap, for a pre-determined model.

Author
Rossen Stoyanchev
Since
5.0

Constructor Summary

AccessConstructor and Description
public
ConcurrentModel()

Construct a new, empty ConcurrentModel.

public
ConcurrentModel(String attributeName, Object attributeValue)

Construct a new ModelMap containing the supplied attribute under the supplied name.

public
ConcurrentModel(Object attributeValue)

Construct a new ModelMap containing the supplied attribute.

Method Summary

Modifier and TypeMethod and Description
public ConcurrentModel
addAllAttributes(Collection<?> attributeValues)

Implements org.springframework.ui.Model.addAllAttributes.

Copy all attributes in the supplied Collection into this Map, using attribute name generation for each element.
public ConcurrentModel
addAllAttributes(Map<String, ?> attributes)

Implements org.springframework.ui.Model.addAllAttributes.

Copy all attributes in the supplied Map into this Map.
public ConcurrentModel
addAttribute(String
the name of the model attribute (never null)
attributeName
,
Object
the model attribute value (ignored if null, just removing an existing entry if any)
attributeValue
)

Implements org.springframework.ui.Model.addAttribute.

Add the supplied attribute under the supplied name.
public ConcurrentModel
addAttribute(Object
the model attribute value (never null)
attributeValue
)

Implements org.springframework.ui.Model.addAttribute.

Add the supplied attribute to this Map using a generated name.
public Map<String, Object>
asMap()

Implements org.springframework.ui.Model.asMap.

Return the current set of model attributes as a Map.
public boolean

Returns:

whether this model contains a corresponding attribute
containsAttribute
(String
the name of the model attribute (never null)
attributeName
)

Implements org.springframework.ui.Model.containsAttribute.

Does this model contain an attribute of the given name?
public Object
getAttribute(String
the name of the model attribute (never null)
attributeName
)

Implements org.springframework.ui.Model.getAttribute.

Return the attribute value for the given name, if any.
public ConcurrentModel
mergeAttributes(Map<String, ?> attributes)

Implements org.springframework.ui.Model.mergeAttributes.

Copy all attributes in the supplied Map into this Map, with existing objects of the same name taking precedence (i.e. not getting replaced).
public Object
put(String
key with which the specified value is to be associated
key
,
Object
value to be associated with the specified key
value
)

Overrides java.util.concurrent.ConcurrentHashMap.put.

Implements java.util.Map.put.

Maps the specified key to the specified value in this table.
public void
putAll(Map<? extends String, ?>
mappings to be stored in this map
map
)

Overrides java.util.concurrent.ConcurrentHashMap.putAll.

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this one.
Inherited from java.util.concurrent.ConcurrentHashMap:
clearcomputecomputeIfAbsentcomputeIfPresentcontainscontainsKeycontainsValueelementsentrySetequalsforEachforEachforEachforEachEntryforEachEntryforEachKeyforEachKeyforEachValueforEachValuegetgetOrDefaulthashCodeisEmptykeyskeySetkeySetmappingCountmergenewKeySetnewKeySetputIfAbsentreducereduceEntriesreduceEntriesreduceEntriesToDoublereduceEntriesToIntreduceEntriesToLongreduceKeysreduceKeysreduceKeysToDoublereduceKeysToIntreduceKeysToLongreduceToDoublereduceToIntreduceToLongreduceValuesreduceValuesreduceValuesToDoublereduceValuesToIntreduceValuesToLongremoveremovereplacereplacereplaceAllsearchsearchEntriessearchKeyssearchValuessizetoStringvalues

Constructor Detail

ConcurrentModelback to summary
public ConcurrentModel()

Construct a new, empty ConcurrentModel.

ConcurrentModelback to summary
public ConcurrentModel(String attributeName, Object attributeValue)

Construct a new ModelMap containing the supplied attribute under the supplied name.

See Also
addAttribute(String, Object)
ConcurrentModelback to summary
public ConcurrentModel(Object attributeValue)

Construct a new ModelMap containing the supplied attribute. Uses attribute name generation to generate the key for the supplied model object.

See Also
addAttribute(Object)

Method Detail

addAllAttributesback to summary
public ConcurrentModel addAllAttributes(Collection<?> attributeValues)

Implements org.springframework.ui.Model.addAllAttributes.

Copy all attributes in the supplied Collection into this Map, using attribute name generation for each element.

Annotations
@Override
See Also
addAttribute(Object)
addAllAttributesback to summary
public ConcurrentModel addAllAttributes(Map<String, ?> attributes)

Implements org.springframework.ui.Model.addAllAttributes.

Copy all attributes in the supplied Map into this Map.

Annotations
@Override
See Also
addAttribute(String, Object)
addAttributeback to summary
public ConcurrentModel addAttribute(String attributeName, Object attributeValue)

Implements org.springframework.ui.Model.addAttribute.

Add the supplied attribute under the supplied name.

Parameters
attributeName:String

the name of the model attribute (never null)

attributeValue:Object

the model attribute value (ignored if null, just removing an existing entry if any)

Annotations
@Override
addAttributeback to summary
public ConcurrentModel addAttribute(Object attributeValue)

Implements org.springframework.ui.Model.addAttribute.

Add the supplied attribute to this Map using a generated name.

Note

Empty Collections are not added to the model when using this method because we cannot correctly determine the true convention name. View code should check for null rather than for empty collections as is already done by JSTL tags.

Parameters
attributeValue:Object

the model attribute value (never null)

Annotations
@Override
asMapback to summary
public Map<String, Object> asMap()

Implements org.springframework.ui.Model.asMap.

Doc from org.springframework.ui.Model.asMap.

Return the current set of model attributes as a Map.

Annotations
@Override
containsAttributeback to summary
public boolean containsAttribute(String attributeName)

Implements org.springframework.ui.Model.containsAttribute.

Does this model contain an attribute of the given name?

Parameters
attributeName:String

the name of the model attribute (never null)

Returns:boolean

whether this model contains a corresponding attribute

Annotations
@Override
getAttributeback to summary
public Object getAttribute(String attributeName)

Implements org.springframework.ui.Model.getAttribute.

Doc from org.springframework.ui.Model.getAttribute.

Return the attribute value for the given name, if any.

Parameters
attributeName:String

the name of the model attribute (never null)

Returns:Object

the corresponding attribute value, or null if none

Annotations
@Override
@Nullable
mergeAttributesback to summary
public ConcurrentModel mergeAttributes(Map<String, ?> attributes)

Implements org.springframework.ui.Model.mergeAttributes.

Copy all attributes in the supplied Map into this Map, with existing objects of the same name taking precedence (i.e. not getting replaced).

Annotations
@Override
putback to summary
public Object put(String key, Object value)

Overrides java.util.concurrent.ConcurrentHashMap.put.

Implements java.util.Map.put.

Doc from java.util.concurrent.ConcurrentHashMap.put.

Maps the specified key to the specified value in this table. Neither the key nor the value can be null.

The value can be retrieved by calling the get method with a key that is equal to the original key.

Parameters
key:String

key with which the specified value is to be associated

value:Object

value to be associated with the specified key

Returns:Object

the previous value associated with key, or null if there was no mapping for key

Annotations
@Override
@Nullable
putAllback to summary
public void putAll(Map<? extends String, ?> map)

Overrides java.util.concurrent.ConcurrentHashMap.putAll.

Implements java.util.Map.putAll.

Doc from java.util.concurrent.ConcurrentHashMap.putAll.

Copies all of the mappings from the specified map to this one. These mappings replace any mappings that this map had for any of the keys currently in the specified map.

Parameters
map:Map<? extends String, ?>

mappings to be stored in this map

Annotations
@Override