Class AbstractBeanConverter<S,T>

java.lang.Object
io.beanmapper.core.converter.AbstractBeanConverter<S,T>
All Implemented Interfaces:
BeanConverter
Direct Known Subclasses:
AnyToEnumConverter, SimpleBeanConverter

public abstract class AbstractBeanConverter<S,T> extends Object implements BeanConverter
Template implementation of a single type converter.
Since:
Jun 18, 2015
Author:
Jeroen van Schagen
  • Field Details

  • Constructor Details

    • AbstractBeanConverter

      protected AbstractBeanConverter()
      Construct a new bean converter, dynamically resolving the source and target class.
    • AbstractBeanConverter

      protected AbstractBeanConverter(Class<?> sourceClass, Class<?> targetClass)
      Construct a new bean converter, manually declaring the source and target class.
      Parameters:
      sourceClass - the source class
      targetClass - the target class
  • Method Details

    • convert

      public final Object convert(BeanMapper beanMapper, Object source, Class<?> targetClass, BeanPropertyMatch beanPropertyMatch)
      Converts the source instance into the desired target type.
      Specified by:
      convert in interface BeanConverter
      Parameters:
      beanMapper - the instance of BeanMapper to use for further mappings
      source - the source instance
      targetClass - the desired target type
      beanPropertyMatch - information on the field pair (source / target)
      Returns:
      the converted source instance
    • doConvert

      protected abstract T doConvert(S source, Class<? extends T> targetClass)
      Convert a source instance to the target type.
      Parameters:
      source - the source instance
      targetClass - the class type to convert to
      Returns:
      the converted source instance
    • match

      public final boolean match(Class<?> sourceClass, Class<?> targetClass)
      Determines if the conversion of our source type to a target type is supported by this converter.
      Specified by:
      match in interface BeanConverter
      Parameters:
      sourceClass - the source class
      targetClass - the target class
      Returns:
      true if the conversion is supported, else false
    • isMatchingSource

      protected boolean isMatchingSource(Class<?> sourceClass)
    • isMatchingTarget

      protected boolean isMatchingTarget(Class<?> targetClass)