Class DTOMapper<T,S,R>

java.lang.Object
io.micronaut.data.runtime.mapper.DTOMapper<T,S,R>
Type Parameters:
T - The entity type
S - 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 Object implements BeanIntrospectionMapper<S,R>
A BeanIntrospectionMapper that reads the result using the specified PersistentEntity and ResultReader and using the BeanIntrospectionMapper.map(Object, Class) allows mapping a result to a introspected Data Transfer Object (DTO).
  • Constructor Details

  • Method Details

    • getConversionService

      public DataConversionService getConversionService()
      Specified by:
      getConversionService in interface TypeMapper<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: TypeMapper
      Read a value for the given name from the given object.
      Specified by:
      read in interface TypeMapper<T,S>
      Parameters:
      object - The object to read from
      name - 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: TypeMapper
      Read a value for the given name from the given object.
      Specified by:
      read in interface TypeMapper<T,S>
      Parameters:
      object - The object to read from
      argument - 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 set
      property - 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 set
      persistedName - The persisted name
      dataType - The data type
      Returns:
      The result
    • getPersistentEntity

      public PersistentEntity getPersistentEntity()
      Returns:
      The entity in use
    • getResultReader

      public ResultReader<S,String> getResultReader()
      Returns:
      the result reader