Interface Mappers

All Superinterfaces:
RuntimeType.Api<MappersConfig>
All Known Subinterfaces:
MapperManager

public interface Mappers extends RuntimeType.Api<MappersConfig>
Mappers manager of all configured mappers.

To map a source to target, you can use either of the map methods defined in this interface, as they make sure that the mapping exists in either space.

  • Method Details

    • builder

      static MappersConfig.Builder builder()
      Create a new builder to customize configuration of Mappers.
      Returns:
      a new fluent API builder
    • create

      static Mappers create()
      Create mappers using defaults.
      Returns:
      create new mappers
    • create

      static Mappers create(MappersConfig config)
      Create new Mappers using the provided configuration.
      Parameters:
      config - mappers configuration
      Returns:
      a new mappers configured from the provided config
    • create

      static Mappers create(Consumer<MappersConfig.Builder> consumer)
      Create new Mappers customizing its configuration.
      Parameters:
      consumer - consumer of configuration builder
      Returns:
      a new configured mappers instance
    • map

      <SOURCE, TARGET> TARGET map(SOURCE source, GenericType<SOURCE> sourceType, GenericType<TARGET> targetType, String... qualifiers) throws MapperException
      Map from source to target.
      Type Parameters:
      SOURCE - type of the source
      TARGET - type of the target
      Parameters:
      source - object to map
      sourceType - type of the source object (to locate the mapper)
      targetType - type of the target object (to locate the mapper)
      qualifiers - qualifiers of the usage (such as http-headers, http, most specific one first)
      Returns:
      result of the mapping
      Throws:
      MapperException - in case the mapper was not found or failed
    • map

      <SOURCE, TARGET> TARGET map(SOURCE source, Class<SOURCE> sourceType, Class<TARGET> targetType, String... qualifiers) throws MapperException
      Map from source to target.
      Type Parameters:
      SOURCE - type of the source
      TARGET - type of the target
      Parameters:
      source - object to map
      sourceType - class of the source object (to locate the mapper)
      targetType - class of the target object (to locate the mapper)
      qualifiers - qualifiers of the usage (such as http-headers, http, most specific one first)
      Returns:
      result of the mapping
      Throws:
      MapperException - in case the mapper was not found or failed
    • mapper

      <SOURCE, TARGET> Optional<Mapper<SOURCE,TARGET>> mapper(GenericType<SOURCE> sourceType, GenericType<TARGET> targetType, String... qualifiers)
      Obtain a mapper for the provided types and qualifiers.
      Type Parameters:
      SOURCE - source type
      TARGET - target type
      Parameters:
      sourceType - type to map from
      targetType - type to map to
      qualifiers - qualifiers of the mapper
      Returns:
      mapper if found