Package io.micronaut.data.runtime.mapper
Class DTOMapper<T,S,R>
java.lang.Object
io.micronaut.data.runtime.mapper.DTOMapper<T,S,R>
- Type Parameters:
T- The entity typeS- The source type.R- The result type
- All Implemented Interfaces:
BeanIntrospectionMapper<S,,R> TypeMapper<S,R>
- Direct Known Subclasses:
SqlDTOMapper
A
BeanIntrospectionMapper that reads the result using the specified
PersistentEntity and ResultReader and using the BeanIntrospectionMapper.map(Object, Class) allows mapping a result to an introspected Data Transfer Object (DTO).-
Constructor Summary
ConstructorsConstructorDescriptionDTOMapper(RuntimePersistentEntity<T> persistentEntity, RuntimePersistentEntity<?> dtoEntity, ResultReader<S, String> resultReader, @Nullable JsonColumnReader<S> jsonColumnReader, DataConversionService conversionService) Default constructor.DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S, String> resultReader, @Nullable JsonColumnReader<S> jsonColumnReader, DataConversionService conversionService) Default constructor.DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S, String> resultReader, DataConversionService conversionService) Default constructor. -
Method Summary
Modifier and TypeMethodDescription@Nullable ObjectRead a value for the given name from the given object.@Nullable Objectread(S resultSet, @NonNull RuntimePersistentProperty<?> property) Read the given property.@Nullable ObjectRead a value for the given name from the given object.@Nullable ObjectRead the value from the given result set for the given persisted name and data type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.data.runtime.mapper.BeanIntrospectionMapper
convert, map
-
Constructor Details
-
DTOMapper
public DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S, String> resultReader, DataConversionService conversionService) Default constructor.- Parameters:
persistentEntity- The entityresultReader- The result readerconversionService-
-
DTOMapper
public DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S, String> resultReader, @Nullable @Nullable JsonColumnReader<S> jsonColumnReader, DataConversionService conversionService) Default constructor.- Parameters:
persistentEntity- The entityresultReader- The result readerjsonColumnReader- The JSON column readerconversionService-
-
DTOMapper
public DTOMapper(RuntimePersistentEntity<T> persistentEntity, RuntimePersistentEntity<?> dtoEntity, ResultReader<S, String> resultReader, @Nullable @Nullable JsonColumnReader<S> jsonColumnReader, DataConversionService conversionService) Default constructor.- Parameters:
persistentEntity- The entitydtoEntity- The dto entityresultReader- The result readerjsonColumnReader- The JSON column readerconversionService-
-
-
Method Details
-
getConversionService
- Specified by:
getConversionServicein interfaceTypeMapper<T,S> - Returns:
- The conversion service to use.
-
read
@Nullable public @Nullable Object read(@NonNull S object, @NonNull @NonNull String name) throws io.micronaut.core.convert.exceptions.ConversionErrorException Description copied from interface:TypeMapperRead a value for the given name from the given object.- Specified by:
readin interfaceTypeMapper<T,S> - Parameters:
object- The object to read fromname- The name- Returns:
- The value
- Throws:
io.micronaut.core.convert.exceptions.ConversionErrorException
-
read
@Nullable public @Nullable Object read(@NonNull S object, @NonNull @NonNull io.micronaut.core.type.Argument<?> argument) Description copied from interface:TypeMapperRead a value for the given name from the given object.- Specified by:
readin interfaceTypeMapper<T,S> - Parameters:
object- The object to read fromargument- The argument- Returns:
- The value
-
read
@Nullable public @Nullable Object read(@NonNull S resultSet, @NonNull @NonNull RuntimePersistentProperty<?> property) Read the given property.- Parameters:
resultSet- The result setproperty- THe property- Returns:
- The result
-
read
@Nullable public @Nullable Object read(@NonNull S resultSet, @NonNull @NonNull String persistedName, @NonNull @NonNull DataType dataType) Read the value from the given result set for the given persisted name and data type.- Parameters:
resultSet- The result setpersistedName- The persisted namedataType- The data type- Returns:
- The result
-
getPersistentEntity
- Returns:
- The entity in use
-
getResultReader
- Returns:
- the result reader
-