Interface GenericModelMapper<ENTITY,​DTO>

  • Type Parameters:
    ENTITY - the element type of the entity object
    DTO - the generic type of the data transfer object
    All Superinterfaces:
    io.github.astrapi69.bean.mapper.BeanMapper<ENTITY,​DTO>, io.github.astrapi69.bean.mapper.GenericMapper<ENTITY,​DTO>
    All Known Implementing Classes:
    AbstractGenericMapper

    public interface GenericModelMapper<ENTITY,​DTO>
    extends io.github.astrapi69.bean.mapper.GenericMapper<ENTITY,​DTO>
    The Interface GenericModelMapper provides the methods for mapping entities to data transfer objects and back.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.lang.Class<DTO> getDtoClass()
      Gets the data transfer object class.
      java.lang.Class<ENTITY> getEntityClass()
      Gets the entity class.
      org.modelmapper.ModelMapper getMapper()
      Gets the mapper.
      default <D,​S>
      java.util.List<D>
      map​(@NonNull java.util.Collection<S> sources, @NonNull java.lang.Class<D> destinationClass)
      Constructs new instances of destinationClass and performs mapping between from source.
      default <D,​S>
      D
      map​(S source, @NonNull java.lang.Class<D> destinationClass)
      Constructs new instance of destinationClass and performs mapping between from source.
      default DTO toDto​(ENTITY entity)
      default java.util.List<DTO> toDtos​(@NonNull java.lang.Iterable<ENTITY> entities)
      default java.util.List<DTO> toDtos​(@NonNull java.util.Collection<ENTITY> entities)
      default java.util.List<ENTITY> toEntities​(@NonNull java.lang.Iterable<DTO> dtos)
      default java.util.List<ENTITY> toEntities​(@NonNull java.util.Collection<DTO> dtos)
      default ENTITY toEntity​(DTO dto)
    • Method Detail

      • getDtoClass

        java.lang.Class<DTO> getDtoClass()
        Gets the data transfer object class.
        Returns:
        the data transfer object class
      • getEntityClass

        java.lang.Class<ENTITY> getEntityClass()
        Gets the entity class.
        Returns:
        the entity class
      • getMapper

        org.modelmapper.ModelMapper getMapper()
        Gets the mapper.
        Returns:
        the mapper
      • map

        default <D,​S> java.util.List<D> map​(@NonNull
                                                  @NonNull java.util.Collection<S> sources,
                                                  @NonNull
                                                  @NonNull java.lang.Class<D> destinationClass)
        Constructs new instances of destinationClass and performs mapping between from source.
        Specified by:
        map in interface io.github.astrapi69.bean.mapper.GenericMapper<ENTITY,​DTO>
        Type Parameters:
        S - the generic type of the source
        D - the generic type of the destinationClass
        Parameters:
        sources - the collection of source objects
        destinationClass - the destination class
        Returns:
        the new instance of destinationClass mapped to source object.
      • map

        default <D,​S> D map​(@NonNull
                                  S source,
                                  @NonNull
                                  @NonNull java.lang.Class<D> destinationClass)
        Constructs new instance of destinationClass and performs mapping between from source.
        Specified by:
        map in interface io.github.astrapi69.bean.mapper.GenericMapper<ENTITY,​DTO>
        Type Parameters:
        D - the generic type of the destinationClass
        S - the generic type of the source
        Parameters:
        source - the source
        destinationClass - the destination class
        Returns:
        the new instance of destinationClass mapped to source object.
      • toDto

        default DTO toDto​(@NonNull
                          ENTITY entity)
        Specified by:
        toDto in interface io.github.astrapi69.bean.mapper.BeanMapper<ENTITY,​DTO>
      • toDtos

        default java.util.List<DTO> toDtos​(@NonNull
                                           @NonNull java.util.Collection<ENTITY> entities)
        Specified by:
        toDtos in interface io.github.astrapi69.bean.mapper.BeanMapper<ENTITY,​DTO>
      • toDtos

        default java.util.List<DTO> toDtos​(@NonNull
                                           @NonNull java.lang.Iterable<ENTITY> entities)
        Specified by:
        toDtos in interface io.github.astrapi69.bean.mapper.BeanMapper<ENTITY,​DTO>
      • toEntities

        default java.util.List<ENTITY> toEntities​(@NonNull
                                                  @NonNull java.util.Collection<DTO> dtos)
        Specified by:
        toEntities in interface io.github.astrapi69.bean.mapper.BeanMapper<ENTITY,​DTO>
      • toEntities

        default java.util.List<ENTITY> toEntities​(@NonNull
                                                  @NonNull java.lang.Iterable<DTO> dtos)
        Specified by:
        toEntities in interface io.github.astrapi69.bean.mapper.BeanMapper<ENTITY,​DTO>
      • toEntity

        default ENTITY toEntity​(@NonNull
                                DTO dto)
        Specified by:
        toEntity in interface io.github.astrapi69.bean.mapper.BeanMapper<ENTITY,​DTO>