Package com.gengoai.conversion
Class CollectionTypeConverter
- java.lang.Object
-
- com.gengoai.conversion.CollectionTypeConverter
-
- All Implemented Interfaces:
TypeConverter
- Direct Known Subclasses:
ConcurrentLinkedDequeTypeConverter
,ConcurrentLinkedQueueTypeConverter
,ConcurrentSkipListSetTypeConverter
,CopyOnWriteArrayListTypeConverter
,CopyOnWriteArraySetTypeConverter
,LinkedBlockingDequeTypeConverter
,LinkedBlockingQueueTypeConverter
,LinkedHashSetTypeConverter
,LinkedListTypeConverter
,ListTypeConverter
,PriorityBlockingQueueTypeConverter
,PriorityQueueTypeConverter
,SetTypeConverter
,StackTypeConverter
,TreeSetTypeConverter
public abstract class CollectionTypeConverter extends Object implements TypeConverter
Base class for converting object into Collections. Conversion is possible for the following types:- Default: A singleton collection is created for the object passed in being converted to the collection element type if possible.
JsonEntry
: arrays as collection of desired type, objects as either collection map entries, or attempts to create an object from the map, primitive - singleton collection- CharSequence: Try to parse as json, if that fails treat as csv with optional []
- Author:
- David B. Bracewell
-
-
Constructor Summary
Constructors Constructor Description CollectionTypeConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Object
convert(Object source, Type... parameters)
Converts an object from one type to another.protected abstract Collection<?>
newCollection()
New collection collection.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.gengoai.conversion.TypeConverter
getConversionType
-
-
-
-
Method Detail
-
convert
public Object convert(Object source, Type... parameters) throws TypeConversionException
Description copied from interface:TypeConverter
Converts an object from one type to another.- Specified by:
convert
in interfaceTypeConverter
- Parameters:
source
- the source objectparameters
- the optional type parameters when using Generics.- Returns:
- the converted object
- Throws:
TypeConversionException
- the source object was not able to be converted to the target type
-
newCollection
protected abstract Collection<?> newCollection()
New collection collection.- Returns:
- the collection
-
-