Interface MapperManager


public interface MapperManager
Mapper 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

    • global

      static MapperManager global()
      Get an instance of the configured global manager. If none is explicitly set, an instance is created using discovered and built-in mappers.
      Returns:
      global mapper manager
    • global

      static void global(MapperManager manager)
      Configure a new global mapper manager.
      Parameters:
      manager - mapper manager to use
    • builder

      static MapperManager.Builder builder()
      Create a fluent API builder to create a customized mapper manager.
      Returns:
      a new builder
    • create

      static MapperManager create()
      Create a mapper manager using only Java Service loader loaded MapperProviders.
      Returns:
      create a new mapper manager from service loader
    • 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