Package org.seedstack.business.assembler
Annotation Type FactoryArgument
-
@Documented @Retention(RUNTIME) @Target({METHOD,ANNOTATION_TYPE}) public @interface FactoryArgument
WhenFluentAssemblerDSL needs to create an aggregate (i.e. when thefromFactory()method is used), this annotation allows to specify a matching between a DTO getter and an argument of an aggregate factory method by position.Example 1: single aggregate
public class CustomerDto { @FactoryArgument(index = 0) public String getName() {...} @FactoryArgument(index = 1) public Date getBirthDate() {...} // No need for annotation here as the address is not part of the factory method public Address getAddress() {...} } @Factory public class CustomerFactory { public Customer createCustomer(String name, Date birthDate); }Example 2: tuple of aggregates
public class RecipeDto { @FactoryArgument(aggregateIndex = 0, index = 0) public String getCustomerName() {...} @FactoryArgument(aggregateIndex = 0, index = 1) public Date getCustomerBirthDate() {...} @FactoryArgument(aggregateIndex = 1, index = 0) public int getOrderId() {...} } @Factory public class CustomerFactory { Customer createCustomer(String name, Date birthDate); } @Factory public class OrderFactory { Customer createOrder(int orderId); }
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description intaggregateIndexOnly used when assembling a tuple of aggregates.intindexSpecifies the position of the aggregate factory method argument the getter will match.
-
-
-
Element Detail
-
aggregateIndex
int aggregateIndex
Only used when assembling a tuple of aggregates. This specifies which aggregate in the tuple (by position) is concerned by theindex()value.- Returns:
- the concerned aggregate index in the tuple.
- Default:
- -1
-
-