Package io.beanmapper.core.collections
Interface CollectionHandler<C>
- All Known Implementing Classes:
AbstractCollectionHandler
,ListCollectionHandler
,MapCollectionHandler
,SetCollectionHandler
public interface CollectionHandler<C>
Deals with the basic collection manipulations required by BeanMapper
-
Method Summary
Modifier and TypeMethodDescriptioncopy
(BeanMapper beanMapper, Class collectionElementClass, C source, C target) Takes all the content from source and offers it to target.int
getTargetCollection
(BeanCollectionUsage collectionUsage, Class<C> preferredCollectionClass, Class<?> collectionElementClass, C targetCollection, CollectionFlusher collectionFlusher, Boolean flushAfterClear) Retrieves either the target collection or creates a new collection instance.getType()
The type of the collection class.boolean
Check if the sourceClass contains the matching class somewhere in its hierarchyint
-
Method Details
-
copy
Takes all the content from source and offers it to target. Every item is handled by BeanMapper before it is stored in target.- Parameters:
beanMapper
- the beanmapper to use for mapping the individual itemscollectionElementClass
- the class of an item within the target collectionsource
- the source collection of itemstarget
- the target collection where the mapped source items will end up- Returns:
- the target collection
-
getTargetCollection
C getTargetCollection(BeanCollectionUsage collectionUsage, Class<C> preferredCollectionClass, Class<?> collectionElementClass, C targetCollection, CollectionFlusher collectionFlusher, Boolean flushAfterClear) Retrieves either the target collection or creates a new collection instance. If CONSTRUCT is set, it will always create a new instance. For the other two options a new instance will only be created if the target collection is null. If CLEAR is used, the target collection will have its clear() method called.- Parameters:
collectionUsage
- the type of collection usage to applypreferredCollectionClass
- the class type of the target collectioncollectionElementClass
- the class type of an element within the target collectiontargetCollection
- the actual target collectioncollectionFlusher
- the flusher to call after clear has been called on a filled collectionflushAfterClear
- whether flush must be called after clear on a collection has been called- Returns:
- the target collection to copy the source collection to
-
getType
The type of the collection class. This will be used to determine if the source collection contains the type somewhere in its super classes or interfaces- Returns:
- the type of the collection class
-
isMatch
Check if the sourceClass contains the matching class somewhere in its hierarchy- Parameters:
clazz
- the class to check for the type- Returns:
- true if the class can be upcast to the type
-
size
-
getGenericParameterIndex
int getGenericParameterIndex()
-