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 Type
    Method
    Description
    copy(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.
    The type of the collection class.
    boolean
    isMatch(Class<?> clazz)
    Check if the sourceClass contains the matching class somewhere in its hierarchy
    int
    size(C targetCollection)
     
  • Method Details

    • copy

      C copy(BeanMapper beanMapper, Class collectionElementClass, C source, C target)
      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 items
      collectionElementClass - the class of an item within the target collection
      source - the source collection of items
      target - 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 apply
      preferredCollectionClass - the class type of the target collection
      collectionElementClass - the class type of an element within the target collection
      targetCollection - the actual target collection
      collectionFlusher - the flusher to call after clear has been called on a filled collection
      flushAfterClear - whether flush must be called after clear on a collection has been called
      Returns:
      the target collection to copy the source collection to
    • getType

      Class<C> 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

      boolean isMatch(Class<?> clazz)
      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

      int size(C targetCollection)
    • getGenericParameterIndex

      int getGenericParameterIndex()