spring-framework / org.springframework.beans.propertyeditors / CustomMapEditor

CustomMapEditor

open class CustomMapEditor : PropertyEditorSupport

Property editor for Maps, converting any source Map to a given target Map type.

Author
Juergen Hoeller

Since
2.0.1

See Also
java.util.Mapjava.util.SortedMap

Constructors

<init>

CustomMapEditor(mapType: Class<out MutableMap<Any?, Any?>>)

Create a new CustomMapEditor for the given target type, keeping an incoming null as-is.

CustomMapEditor(mapType: Class<out MutableMap<Any?, Any?>>, nullAsEmptyMap: Boolean)

Create 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.

Functions

getAsText

open fun getAsText(): String

This implementation returns null to indicate that there is no appropriate text representation.

setAsText

open fun setAsText(text: String): Unit

Convert the given text value to a Map with a single element.

setValue

open fun setValue(value: Any): Unit

Convert the given value to a Map of the target type.