Class OptionalToObjectConverter

java.lang.Object
io.beanmapper.core.converter.impl.OptionalToObjectConverter
All Implemented Interfaces:
BeanConverter

public class OptionalToObjectConverter extends Object implements BeanConverter
This converter facilitates the conversion of an arbitrary amount of Optional wrappers, however, support for complex datastructures, such as Maps, Sets, List, etc. is limited to a single layer. As such, if the user requires support deeper layers of complex datastructures within Optionals, they should revise their system design, and if that does not solve the problem, create a custom converters for their specific conversion.
  • Constructor Details

    • OptionalToObjectConverter

      public OptionalToObjectConverter()
  • Method Details

    • convert

      public <S, T> T convert(BeanMapper beanMapper, S source, Class<T> 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
    • match

      public boolean match(Class<?> sourceClass, Class<?> targetClass)
      Determines whether 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