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
public class DTOMapper<T,S,R> extends java.lang.Object implements BeanIntrospectionMapper<S,R>
ABeanIntrospectionMapperthat reads the result using the specifiedPersistentEntityandResultReaderand using theBeanIntrospectionMapper.map(Object, Class)allows mapping a result to a introspected Data Transfer Object (DTO).
-
-
Constructor Summary
Constructors Constructor Description DTOMapper(RuntimePersistentEntity<T> persistentEntity, RuntimePersistentEntity<?> dtoEntity, ResultReader<S,java.lang.String> resultReader, io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)Default constructor.DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S,java.lang.String> resultReader, DataConversionService<?> conversionService)Default constructor.DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S,java.lang.String> resultReader, io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataConversionService<?>getConversionService()PersistentEntitygetPersistentEntity()ResultReader<S,java.lang.String>getResultReader()java.lang.Objectread(S object, io.micronaut.core.type.Argument<?> argument)Read a value for the given name from the given object.java.lang.Objectread(S resultSet, RuntimePersistentProperty<?> property)Read the given property.java.lang.Objectread(S object, java.lang.String name)Read a value for the given name from the given object.java.lang.Objectread(S resultSet, java.lang.String persistedName, DataType dataType)Read 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, wait
-
Methods inherited from interface io.micronaut.data.runtime.mapper.BeanIntrospectionMapper
convert, map
-
-
-
-
Constructor Detail
-
DTOMapper
public DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S,java.lang.String> resultReader, DataConversionService<?> conversionService)
Default constructor.- Parameters:
persistentEntity- The entityresultReader- The result readerconversionService-
-
DTOMapper
public DTOMapper(RuntimePersistentEntity<T> persistentEntity, ResultReader<S,java.lang.String> resultReader, @Nullable io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)
Default constructor.- Parameters:
persistentEntity- The entityresultReader- The result readerjsonCodec- The JSON codecconversionService-
-
DTOMapper
public DTOMapper(RuntimePersistentEntity<T> persistentEntity, RuntimePersistentEntity<?> dtoEntity, ResultReader<S,java.lang.String> resultReader, @Nullable io.micronaut.http.codec.MediaTypeCodec jsonCodec, DataConversionService<?> conversionService)
Default constructor.- Parameters:
persistentEntity- The entitydtoEntity- The dto entityresultReader- The result readerjsonCodec- The JSON codecconversionService-
-
-
Method Detail
-
getConversionService
public DataConversionService<?> getConversionService()
- Specified by:
getConversionServicein interfaceTypeMapper<T,S>- Returns:
- The conversion service to use.
-
read
@Nullable public java.lang.Object read(@NonNull S object, @NonNull java.lang.String name) throws io.micronaut.core.convert.exceptions.ConversionErrorExceptionDescription 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 java.lang.Object read(@NonNull S object, @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 java.lang.Object read(@NonNull S resultSet, @NonNull RuntimePersistentProperty<?> property)Read the given property.- Parameters:
resultSet- The result setproperty- THe property- Returns:
- The result
-
read
@Nullable public java.lang.Object read(@NonNull S resultSet, @NonNull java.lang.String persistedName, @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
public PersistentEntity getPersistentEntity()
- Returns:
- The entity in use
-
getResultReader
public ResultReader<S,java.lang.String> getResultReader()
- Returns:
- the result reader
-
-