By default registered for Set, SortedSet and List, to automatically convert any given Collection to one of those target types if the type does not match the target property.
java.util.Collection , java.util.Set , java.util.SortedSet , java.util.List
| Modifier and Type | Field and Description |
|---|---|
| private final Class | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | CustomCollectionEditor(Class<? extends Collection<E>>
the target type, which needs to be a
sub-interface of Collection or a concrete Collection class collectionType)Create a new CustomCollectionEditor for the given target type,
keeping an incoming |
| public | CustomCollectionEditor(Class<? extends Collection<E>>
the target type, which needs to be a
sub-interface of Collection or a concrete Collection class collectionType, boolean whether to convert an incoming nullAsEmptyCollection)null
value to an empty Collection (of the appropriate type)Create a new CustomCollectionEditor for the given target type. |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | alwaysCreateNewCollection()
Return whether to always create a new Collection, even if the type of the passed-in Collection already matches. |
| protected Object | Returns: the element to be used in the target Collectionthe source element element)Hook to convert each encountered Collection/array element. |
| protected Collection | Returns: the new Collection instancea sub-interface of Collection collectionType, int the initial capacity initialCapacity)Create a Collection of the given type, with the given initial capacity (if supported by the Collection type). |
| public String | getAsText()
Overrides java. Implements java. This implementation returns |
| public void | setAsText(String
The string to be parsed. text)Overrides java. Implements java. Convert the given text value to a Collection with a single element. |
| public void | setValue(Object
The new target object to be edited. Note that this
object should not be modified by the PropertyEditor, rather
the PropertyEditor should create a new object to hold any
modified value. value)Overrides java. Implements java. Convert the given value to a Collection of the target type. |
| collectionType | back to summary |
|---|---|
private final Class<? extends Collection<E>> collectionType
| |
| nullAsEmptyCollection | back to summary |
|---|---|
| private final boolean nullAsEmptyCollection | |
| CustomCollectionEditor | back to summary |
|---|---|
| public CustomCollectionEditor(Class<? extends Collection<E>> collectionType) Create a new CustomCollectionEditor for the given target type,
keeping an incoming
| |
| CustomCollectionEditor | back to summary |
|---|---|
| public CustomCollectionEditor(Class<? extends Collection<E>> collectionType, boolean nullAsEmptyCollection) Create a new CustomCollectionEditor 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 Collection type or an array, it will be converted to a default implementation of the given Collection type. If the value is anything else, a target Collection with that single value will be created. The default Collection implementations are: ArrayList for List, TreeSet for SortedSet, and LinkedHashSet for Set.
| |
| alwaysCreateNewCollection | back to summary |
|---|---|
| protected boolean alwaysCreateNewCollection() Return whether to always create a new Collection, even if the type of the passed-in Collection already matches. Default is "false"; can be overridden to enforce creation of a new Collection, for example to convert elements in any case.
| |
| convertElement | back to summary |
|---|---|
| protected Object convertElement(Object element) Hook to convert each encountered Collection/array element. The default implementation simply returns the passed-in element as-is. Can be overridden to perform conversion of certain elements, for example String to Integer if a String array comes in and should be converted to a Set of Integer objects. Only called if actually creating a new Collection!
This is by default not the case if the type of the passed-in Collection
already matches. Override
| |
| createCollection | back to summary |
|---|---|
| protected Collection Create a Collection of the given type, with the given initial capacity (if supported by the Collection type).
| |
| getAsText | back to summary |
|---|---|
| public String getAsText() Overrides java. Implements java. This implementation returns
| |
| setAsText | back to summary |
|---|---|
| public void setAsText(String text) throws IllegalArgumentException Overrides java. Implements java. Convert the given text value to a Collection with a single element.
| |
| setValue | back to summary |
|---|---|
| public void setValue(Object value) Overrides java. Implements java. Convert the given value to a Collection of the target type.
| |