Interface MapperProvider

All Known Implementing Classes:
DbMapperProviderImpl
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface MapperProvider
Java Service loader service to get mappers.

Mapper provider provides mappers based on the source and target types and a qualifier. Generic mappers should always return MapperProvider.Support.COMPATIBLE, so specific mappers can be created for qualified usages. This is to support a different date/time mapper depending on usage. For this case we may have the following qualifiers (example, not normative): config,jdbc-oracle,http-header,http-query. Qualifiers should be defined by a constant in each component using mapping.

  • Method Details

    • mapper

      MapperProvider.ProviderResponse mapper(Class<?> sourceClass, Class<?> targetClass, String qualifier)
      Find a mapper that is capable of mapping from source to target classes. Qualifiers are defined by each component using mapping. In case of clashing qualifiers, the first mapper that returns MapperProvider.Support.SUPPORTED will be chosen.
      Parameters:
      sourceClass - class of the source
      targetClass - class of the target
      qualifier - qualifiers of this mapping (such as config or http-headers, may be empty for default
      Returns:
      a mapper that is capable of mapping (or converting) sources to targets
    • mapper

      default MapperProvider.ProviderResponse mapper(GenericType<?> sourceType, GenericType<?> targetType, String qualifier)
      Find a mapper that is capable of mapping from source to target types. This method supports mapping to/from types that contain generics.
      Parameters:
      sourceType - generic type of the source
      targetType - generic type of the target
      qualifier - qualifier of the mapping - this is to allow multiple mappings for the same type depending on context such as HTTP Headers may use a different date mapping than database operations
      Returns:
      a mapper that is capable of mapping (or converting) sources to targets, default implementation calls mapper(Class, Class, java.lang.String) for types that are not generic, MapperProvider.ProviderResponse.unsupported() otherwise.