Package io.beanmapper

Class BeanMapper

java.lang.Object
io.beanmapper.BeanMapper

public final class BeanMapper extends Object
Class that is responsible first for understanding the semantics of the source and target objects. Once that has been determined, the applicable properties will be copied from source to target.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BeanMapper(Configuration configuration)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    <S, T> Collection<T>
    map(Collection<S> collection, Class<T> elementInCollectionClass)
    Maps the source collection to a new target collection.
    <S, T> List<T>
    map(List<S> list, Class<T> elementInListClass)
    Maps the source list of elements to a new target list.
    <K, S, T> Map<K,T>
    map(Map<K,S> map, Class<T> mapValueClass)
    Maps the source map of elements to a new target map.
    <S, T> Optional<T>
    map(Optional<S> source, Class<T> targetClass)
    Copies the values from the optional source object to a newly constructed target instance
    <S, T> Queue<T>
    map(Queue<S> queue, Class<T> elementInQueueClass)
    Maps the source queue to a new target queue.
    <S, T> Set<T>
    map(Set<S> set, Class<T> elementInSetClass)
    Maps the source set of elements to a new target set.
    <S, T> T
    map(S source)
     
    <S, T> T[]
    map(S[] sourceArray, Class<T> targetClass)
    Maps the source array to an array with the type of the target class.
    <S, T> T
    map(S source, Class<T> targetClass)
    Copies the values from the source object to a newly constructed target instance
    map(S source, P target)
    Maps the source to the given target.
    <S, T> T
    map(S source, T target)
    Copies the values from the source object to an existing target instance
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • map

      public <S, T> T map(S source)
    • map

      public <S, T> T map(S source, T target)
      Copies the values from the source object to an existing target instance
      Type Parameters:
      S - the instance from which the properties get copied.
      T - the instance to which the properties get copied
      Parameters:
      source - source instance of the properties
      target - target instance for the properties
      Returns:
      the original target instance containing all applicable properties
    • map

      public <S, T> Optional<T> map(Optional<S> source, Class<T> targetClass)
      Copies the values from the optional source object to a newly constructed target instance
      Type Parameters:
      S - the instance from which the properties get copied
      T - the instance to which the properties get copied
      Parameters:
      source - optional source instance of the properties
      targetClass - class of the target, needs to be constructed as the target instance
      Returns:
      the optional target instance containing all applicable properties
    • map

      public <S, P extends ParameterizedType> Object map(S source, P target)
      Maps the source to the given target.

      If the target is a Collection, Map, or Optional, the object wrapped in the source, will be mapped to the type corresponding to the relevant type argument.

      Type Parameters:
      S - Type of the source.
      P - Type of the specific implementation of ParameterizedType used as the target.
      Parameters:
      source - Source instance of the properties.
      target - Implementation of ParameterizedType, which provides the information necessary to map elements to the correct type.
      Returns:
      The result of the mapping.
    • map

      public <S, T> T map(S source, Class<T> targetClass)
      Copies the values from the source object to a newly constructed target instance
      Type Parameters:
      S - The instance from which the properties get copied
      T - the instance to which the properties get copied
      Parameters:
      source - source instance of the properties
      targetClass - class of the target, needs to be constructed as the target instance
      Returns:
      the target instance containing all applicable properties
    • map

      public <S, T> T[] map(S[] sourceArray, Class<T> targetClass)
      Maps the source array to an array with the type of the target class.
      Type Parameters:
      S - The type of the elements in the source array.
      T - The type of the elements in the target array.
      Parameters:
      sourceArray - The source array.
      targetClass - The class to which the elements from the source array will be converted to.
      Returns:
      A newly constructed array of the type of the target class.
    • map

      public <S, T> Collection<T> map(Collection<S> collection, Class<T> elementInCollectionClass)
      Maps the source collection to a new target collection.

      The type of the target collection is determined automatically from the actual type of the source collection. If the source

      Type Parameters:
      S - The type up the elements in the source collection.
      T - The type of the target, to which the source elements will be mapped.
      Parameters:
      collection - - The source collection
      elementInCollectionClass - - The class of each element in the target list.
      Returns:
      The target collection with mapped source collection elements.
    • map

      public <S, T> List<T> map(List<S> list, Class<T> elementInListClass)
      Maps the source list of elements to a new target list. Convenience operator
      Type Parameters:
      S - the class type of the source list
      T - the class type of an element in the target list
      Parameters:
      list - the source list
      elementInListClass - the class of each element in the target list
      Returns:
      the target list with mapped source list elements
    • map

      public <S, T> Set<T> map(Set<S> set, Class<T> elementInSetClass)
      Maps the source set of elements to a new target set. Convenience operator
      Type Parameters:
      S - the class type of the source set
      T - the class type of an element in the target set
      Parameters:
      set - the source set
      elementInSetClass - the class of each element in the target set
      Returns:
      the target set with mapped source set elements
    • map

      public <S, T> Queue<T> map(Queue<S> queue, Class<T> elementInQueueClass)
      Maps the source queue to a new target queue. Convenience operator.
      Type Parameters:
      S - The class type of the source queue.
      T - The class type of the elements in the target queue.
      Parameters:
      queue - The source queue.
      elementInQueueClass - The class of each element in the target queue.
      Returns:
      The target queue with mapped source queue elements.
    • map

      public <K, S, T> Map<K,T> map(Map<K,S> map, Class<T> mapValueClass)
      Maps the source map of elements to a new target map. Convenience operator
      Type Parameters:
      K - the class type of a key in both source and target map
      T - the class type of a value in the target map
      S - the class type of the source map
      Parameters:
      map - the source map
      mapValueClass - the class of each value in the target map
      Returns:
      the target map with literal source set keys and mapped source set values
    • wrap

      public BeanMapperBuilder wrap()
    • getConfiguration

      public Configuration getConfiguration()