- All Superinterfaces:
RuntimeType.Api<MappersConfig>
- All Known Subinterfaces:
MapperManager
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.
- If you call
map(Object, Class, Class, String...)
and no mapper is found for the class pair, the implementation calls themap(Object, io.helidon.common.GenericType, io.helidon.common.GenericType, String...)
withGenericType
s created for each parameters - If you call
map(Object, io.helidon.common.GenericType, io.helidon.common.GenericType, String...)
and no mapper is found for theGenericType
pair, an attempt is to locate a mapper for the underlying class *IF* the generic type represents a simple class (e.g. not a generic type declaration)
-
Method Summary
Modifier and TypeMethodDescriptionstatic MappersConfig.Builder
builder()
Create a new builder to customize configuration ofMappers
.static Mappers
create()
Create mappers using defaults.static Mappers
create
(MappersConfig config) Create newMappers
using the provided configuration.static Mappers
create
(Consumer<MappersConfig.Builder> consumer) Create newMappers
customizing its configuration.<SOURCE,
TARGET>
TARGETmap
(SOURCE source, GenericType<SOURCE> sourceType, GenericType<TARGET> targetType, String... qualifiers) Map from source to target.<SOURCE,
TARGET>
TARGETMap from source to target.mapper
(GenericType<SOURCE> sourceType, GenericType<TARGET> targetType, String... qualifiers) Obtain a mapper for the provided types and qualifiers.Methods inherited from interface io.helidon.builder.api.RuntimeType.Api
prototype
-
Method Details
-
builder
Create a new builder to customize configuration ofMappers
.- Returns:
- a new fluent API builder
-
create
Create mappers using defaults.- Returns:
- create new mappers
-
create
Create newMappers
using the provided configuration.- Parameters:
config
- mappers configuration- Returns:
- a new mappers configured from the provided config
-
create
Create newMappers
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 sourceTARGET
- type of the target- Parameters:
source
- object to mapsourceType
- 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 ashttp-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 sourceTARGET
- type of the target- Parameters:
source
- object to mapsourceType
- 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 ashttp-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 typeTARGET
- target type- Parameters:
sourceType
- type to map fromtargetType
- type to map toqualifiers
- qualifiers of the mapper- Returns:
- mapper if found
-