| java.lang.Object | ||
| ↳ | java.beans.PropertyEditorSupport | |
| ↳ | org.springframework.beans.propertyeditors.CustomMapEditor | |
Property editor for Maps, converting any source Map to a given target Map type.
Map| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Create a new CustomMapEditor for the given target type,
keeping an incoming
null as-is. | |||||||||||
Create a new CustomMapEditor for the given target type.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
This implementation returns
null to indicate that
there is no appropriate text representation. | |||||||||||
Convert the given text value to a Map with a single element.
| |||||||||||
Convert the given value to a Map of the target type.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Return whether to always create a new Map,
even if the type of the passed-in Map already matches.
| |||||||||||
Hook to convert each encountered Map key.
| |||||||||||
Hook to convert each encountered Map value.
| |||||||||||
Create a Map of the given type, with the given
initial capacity (if supported by the Map type).
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.beans.PropertyEditorSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.beans.PropertyEditor
| |||||||||||
Create a new CustomMapEditor for the given target type,
keeping an incoming null as-is.
| mapType | the target type, which needs to be a sub-interface of Map or a concrete Map class |
|---|
MapHashMapLinkedHashMapCreate a new CustomMapEditor for the given target type.
If the incoming value is of the given type, it will be used as-is. If it is a different Map type or an array, it will be converted to a default implementation of the given Map type. If the value is anything else, a target Map with that single value will be created.
The default Map implementations are: TreeMap for SortedMap, and LinkedHashMap for Map.
| mapType | the target type, which needs to be a sub-interface of Map or a concrete Map class |
|---|---|
| nullAsEmptyMap | ap whether to convert an incoming null
value to an empty Map (of the appropriate type) |
MapLinkedHashMapThis implementation returns null to indicate that
there is no appropriate text representation.
Convert the given text value to a Map with a single element.
| IllegalArgumentException |
|---|
Return whether to always create a new Map, even if the type of the passed-in Map already matches.
Default is "false"; can be overridden to enforce creation of a new Map, for example to convert elements in any case.
Hook to convert each encountered Map key. The default implementation simply returns the passed-in key as-is.
Can be overridden to perform conversion of certain keys, for example from String to Integer.
Only called if actually creating a new Map!
This is by default not the case if the type of the passed-in Map
already matches. Override alwaysCreateNewMap() to
enforce creating a new Map in every case.
| key | the source key |
|---|
Hook to convert each encountered Map value. The default implementation simply returns the passed-in value as-is.
Can be overridden to perform conversion of certain values, for example from String to Integer.
Only called if actually creating a new Map!
This is by default not the case if the type of the passed-in Map
already matches. Override alwaysCreateNewMap() to
enforce creating a new Map in every case.
| value | the source value |
|---|
Create a Map of the given type, with the given initial capacity (if supported by the Map type).
| mapType | a sub-interface of Map |
|---|---|
| initialCapacity | the initial capacity |