
org.seedstack.business.assembler.dsl.FluentAssembler Maven / Gradle / Ivy
/*
* Copyright © 2013-2024, The SeedStack authors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.business.assembler.dsl;
import java.util.stream.Stream;
import org.javatuples.Tuple;
import org.seedstack.business.domain.AggregateRoot;
import org.seedstack.business.pagination.Page;
/**
* FluentAssembler is a DSL aimed at automating the most frequent tasks that occurs when mapping
* aggregates to Data Transfer Objects (DTO) and back. It works seamlessly on individual objects,
* {@link Stream}s, {@link Iterable}s, and {@link Page}s. It also works with tuples of aggregates.
*
* When merging a DTO back into aggregate(s), FluentAssembler can use a {@link
* org.seedstack.business.domain.Repository} and/or a {@link org.seedstack.business.domain.Factory}
* to obtain the aggregate(s).
*/
public interface FluentAssembler {
/**
* Assembles an aggregate.
*
* @param the type of the aggregate root.
* @param the type of the aggregate root identifier.
* @param aggregateRoot the aggregate root to assemble.
* @return the next type for FluentAssembler DSL.
*/
, I> AssembleSingleWithQualifier assemble(A aggregateRoot);
/**
* Assembles a stream of aggregates.
*
* @param the type of the aggregate root.
* @param the type of the aggregate root identifier.
* @param stream the stream of aggregate roots to assemble.
* @return the next type for FluentAssembler DSL.
*/
, I> AssembleMultipleWithQualifier assemble(Stream stream);
/**
* Assembles an iterable of aggregates.
*
* @param the type of the aggregate root.
* @param the type of the aggregate root identifier.
* @param iterable the iterable of aggregate roots to assemble.
* @return the next type for FluentAssembler DSL.
*/
, I> AssembleMultipleWithQualifier assemble(Iterable iterable);
/**
* Assembles a page of aggregates.
*
* @param the type of the aggregate root.
* @param the type of the aggregate root identifier.
* @param page the page of aggregate roots to assemble.
* @return the next type for FluentAssembler DSL.
*/
, I> AssemblePageWithQualifier assemble(Page page);
/**
* Assembles a tuple of aggregates into a single DTO.
*
* @param the type of the tuple.
* @param tuple the tuple of aggregate roots to assemble.
* @return the next type for FluentAssembler DSL.
*/
AssembleSingleWithQualifier assembleTuple(T tuple);
/**
* Assembles a stream of tuple of aggregates.
*
* @param the type of the tuple.
* @param stream the stream of tuples of aggregate roots to assemble.
* @return the next type for FluentAssembler DSL.
*/
AssembleMultipleWithQualifier assembleTuples(Stream stream);
/**
* Assembles an iterable of tuple of aggregates.
*
* @param the type of the tuple.
* @param iterable the iterable of tuples of aggregate roots to assemble.
* @return the next type for FluentAssembler DSL.
*/
AssembleMultipleWithQualifier assembleTuples(Iterable iterable);
/**
* Assembles a page of tuple of aggregates.
*
* @param the type of the tuple.
* @param page the page of tuples of aggregate roots to assemble.
* @return the next type for FluentAssembler DSL.
*/
AssemblePageWithQualifier assembleTuples(Page page);
/**
* Merges a DTO back into an aggregate.
*
* @param the DTO type.
* @param dto the dto to merge
* @return the next type for FluentAssembler DSL.
*/
MergeSingleWithQualifier merge(D dto);
/**
* Merges a stream of DTO back into aggregates.
*
* @param the DTO type.
* @param stream the stream of DTO.
* @return the next type for FluentAssembler DSL.
*/
MergeMultipleWithQualifier merge(Stream stream);
/**
* Merges an iterable of DTO back into aggregates.
*
* @param the DTO type.
* @param iterable the iterable of DTO.
* @return the next type for FluentAssembler DSL.
*/
MergeMultipleWithQualifier merge(Iterable iterable);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy