Package io.beanmapper

Class BeanMapper

java.lang.Object
io.beanmapper.BeanMapper

public 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 Details

  • Method Details

    • map

      public Object map(Object 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> 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> 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 <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
    • getConfiguration

      public final Configuration getConfiguration()
    • config

      public BeanMapperBuilder config()
      Deprecated.
      use wrap() instead
      Returns:
      BeanMapperBuilder
    • wrapConfig

      public BeanMapperBuilder wrapConfig()
      Deprecated.
      use wrap() instead
      Returns:
      BeanMapperBuilder
    • wrap

      public BeanMapperBuilder wrap()