Interface Assembler<A,​D>

  • Type Parameters:
    A - the type of the aggregate root or of the Tuple of aggregate roots.
    D - the type of the DTO.

    public interface Assembler<A,​D>
    An assembler implementation contains the logic responsible for assembling an aggregate (or a tuple of multiple aggregates) into into a DTO and back. Assemblers can be used by the FluentAssembler DSL to execute complex mapping tasks.
    See Also:
    FluentAssembler
    • Method Detail

      • createDtoFromAggregate

        default D createDtoFromAggregate​(A sourceAggregate)
        Creates a new DTO and merge the given aggregate into it. Method createDto() is called to create the DTO instance, then mergeAggregateIntoDto(Object, Object) is called to do the merge.
        Parameters:
        sourceAggregate - the source aggregate.
        Returns:
        the resulting dto.
      • mergeAggregateIntoDto

        void mergeAggregateIntoDto​(A sourceAggregate,
                                   D targetDto)
        Merge a source aggregate into an existing target DTO.
        Parameters:
        sourceAggregate - the source aggregate.
        targetDto - the target dto.
      • mergeDtoIntoAggregate

        void mergeDtoIntoAggregate​(D sourceDto,
                                   A targetAggregate)
        Merges a source DTO into an existing target aggregate root.
        Parameters:
        sourceDto - the source dto.
        targetAggregate - the target aggregate.
      • createDto

        D createDto()
        This method is responsible for creating a new DTO instance during the assembling task.
        Returns:
        a newly-created DTO instance.
        See Also:
        createDtoFromAggregate(Object)
      • getDtoClass

        Class<D> getDtoClass()
        The DTO class the assemblers works on.
        Returns:
        the DTO class.