Class AbstractMapStrategy

java.lang.Object
io.beanmapper.strategy.AbstractMapStrategy
All Implemented Interfaces:
MapStrategy
Direct Known Subclasses:
MapCollectionStrategy, MapToDynamicClassStrategy, MapToInstanceStrategy

public abstract class AbstractMapStrategy extends Object implements MapStrategy
  • Field Details

    • logger

      protected final org.slf4j.Logger logger
  • Constructor Details

  • Method Details

    • getConfiguration

      public Configuration getConfiguration()
    • getBeanMapper

      public BeanMapper getBeanMapper()
    • getConstructorArguments

      public <S> ConstructorArguments getConstructorArguments(S source, BeanMatch beanMatch)
    • getBeanMatch

      public <T, S> BeanMatch getBeanMatch(Class<S> sourceClazz, Class<T> targetClazz)
    • convert

      public Object convert(Object value, Class<?> targetClass, BeanPropertyMatch beanPropertyMatch)
      Converts a value into the target class.
      Parameters:
      value - the value to convert
      targetClass - the target class
      beanPropertyMatch - contains the fields belonging to the source/target field match
      Returns:
      the converted value
    • processProperties

      public <S, T> T processProperties(S source, T target, BeanMatch beanMatch)
      Try to match the source fields on the target fields from the given classes. First get all fields on the right level with method getAllFields. Second match the fields and handle encapsulated classes. Finally copy the data from the source to the target.
      Type Parameters:
      S - The source type
      T - The target type
      Parameters:
      source - The source from which the values get copied.
      target - The target to which the values get copied.
      beanMatch - the matchup of source and target
      Returns:
      A filled target object.
    • isMappableClass

      public boolean isMappableClass(Class<?> clazz)
      Verifies whether the class is part of the beans which may be mapped by the BeanMapper. This logic is used when nested classes are encountered which need to be treated in a similar way as the main source/ target classes.
      Parameters:
      clazz - the class to be verified against the allowed packages
      Returns:
      true if the class may be mapped, false if it may not
    • isMappable

      public boolean isMappable(String packageName)
      Verifies whether the package is part of the beans which may be mapped by the bean mapper. This logic is used when nested classes are encountered which need to be treated in a similar way as the main source/ target classes.
      Parameters:
      packageName - the package
      Returns:
      true if the class may be mapped, false if it may not
    • getConverterOptional

      public BeanConverter getConverterOptional(Class<?> sourceClass, Class<?> targetClass)