- 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.
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.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final record
Response of a provider.static enum
How does this provider support the type. -
Method Summary
Modifier and TypeMethodDescriptiondefault MapperProvider.ProviderResponse
mapper
(GenericType<?> sourceType, GenericType<?> targetType, String qualifier) Find a mapper that is capable of mapping from source to target types.Find a mapper that is capable of mapping from source to target classes.
-
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 returnsMapperProvider.Support.SUPPORTED
will be chosen.- Parameters:
sourceClass
- class of the sourcetargetClass
- class of the targetqualifier
- qualifiers of this mapping (such asconfig
orhttp-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 sourcetargetType
- generic type of the targetqualifier
- 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.
-