Package org.seedstack.business.assembler
Interface Assembler<A,D>
-
- Type Parameters:
A- the type of the aggregate root or of theTupleof 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 theFluentAssemblerDSL to execute complex mapping tasks.- See Also:
FluentAssembler
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description DcreateDto()This method is responsible for creating a new DTO instance during the assembling task.default DcreateDtoFromAggregate(A sourceAggregate)Creates a new DTO and merge the given aggregate into it.Class<D>getDtoClass()The DTO class the assemblers works on.voidmergeAggregateIntoDto(A sourceAggregate, D targetDto)Merge a source aggregate into an existing target DTO.voidmergeDtoIntoAggregate(D sourceDto, A targetAggregate)Merges a source DTO into an existing target aggregate root.
-
-
-
Method Detail
-
createDtoFromAggregate
default D createDtoFromAggregate(A sourceAggregate)
Creates a new DTO and merge the given aggregate into it. MethodcreateDto()is called to create the DTO instance, thenmergeAggregateIntoDto(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)
-
-