Package jodd.typeconverter.impl
Class CollectionConverter<T>
- java.lang.Object
-
- jodd.typeconverter.impl.CollectionConverter<T>
-
- All Implemented Interfaces:
TypeConverter<java.util.Collection<T>>
public class CollectionConverter<T> extends java.lang.Object implements TypeConverter<java.util.Collection<T>>
Collection converter.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Class<? extends java.util.Collection>collectionTypeprotected java.lang.Class<T>targetComponentTypeprotected TypeConverterManagertypeConverterManager
-
Constructor Summary
Constructors Constructor Description CollectionConverter(java.lang.Class<? extends java.util.Collection> collectionType, java.lang.Class<T> targetComponentType)CollectionConverter(TypeConverterManager typeConverterManager, java.lang.Class<? extends java.util.Collection> collectionType, java.lang.Class<T> targetComponentType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<T>convert(java.lang.Object value)Converts object received as parameter into object of another class.protected java.util.Collection<T>convertCollectionToCollection(java.util.Collection value)Converts collection value to target collection.protected java.util.Collection<T>convertPrimitiveArrayToCollection(java.lang.Object value, java.lang.Class primitiveComponentType)Converts primitive array to target collection.protected java.util.Collection<T>convertToSingleElementCollection(java.lang.Object value)Creates a collection with single element.protected TconvertType(java.lang.Object value)Converts type using type converter manager.protected java.util.Collection<T>convertValueToCollection(java.lang.Object value)Converts non-collection value to collection.protected java.util.Collection<T>createCollection(int length)Creates new collection of target component type.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jodd.typeconverter.TypeConverter
convert
-
-
-
-
Field Detail
-
typeConverterManager
protected final TypeConverterManager typeConverterManager
-
collectionType
protected final java.lang.Class<? extends java.util.Collection> collectionType
-
targetComponentType
protected final java.lang.Class<T> targetComponentType
-
-
Constructor Detail
-
CollectionConverter
public CollectionConverter(java.lang.Class<? extends java.util.Collection> collectionType, java.lang.Class<T> targetComponentType)
-
CollectionConverter
public CollectionConverter(TypeConverterManager typeConverterManager, java.lang.Class<? extends java.util.Collection> collectionType, java.lang.Class<T> targetComponentType)
-
-
Method Detail
-
convert
public java.util.Collection<T> convert(java.lang.Object value)
Description copied from interface:TypeConverterConverts object received as parameter into object of another class. For example, anIntegerconverter tries to convert given objects into targetIntegerobject. Converters should try all reasonable ways of conversion into target object, depending on target type.- Specified by:
convertin interfaceTypeConverter<T>- Parameters:
value- object to convert from- Returns:
- resulting object converted to target type
-
convertType
protected T convertType(java.lang.Object value)
Converts type using type converter manager.
-
createCollection
protected java.util.Collection<T> createCollection(int length)
Creates new collection of target component type. Default implementation uses reflection to create an collection of target type. Override it for better performances.
-
convertToSingleElementCollection
protected java.util.Collection<T> convertToSingleElementCollection(java.lang.Object value)
Creates a collection with single element.
-
convertValueToCollection
protected java.util.Collection<T> convertValueToCollection(java.lang.Object value)
Converts non-collection value to collection.
-
convertCollectionToCollection
protected java.util.Collection<T> convertCollectionToCollection(java.util.Collection value)
Converts collection value to target collection. Each element is converted to target component type.
-
convertPrimitiveArrayToCollection
protected java.util.Collection<T> convertPrimitiveArrayToCollection(java.lang.Object value, java.lang.Class primitiveComponentType)
Converts primitive array to target collection.
-
-