@Documented @Retention(value=RUNTIME) @Target(value={METHOD,ANNOTATION_TYPE}) public @interface FactoryArgument
FluentAssembler
DSL needs to create an aggregate (i.e. when the fromFactory()
method is used), this annotation allows to specify a matching between a DTO getter
and an argument of an aggregate factory method by position.
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); }
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); }
Modifier and Type | Optional Element and Description |
---|---|
int |
aggregateIndex
Only used when assembling a tuple of aggregates.
|
int |
index
Specifies the position of the aggregate factory method argument the getter will match.
|
public abstract int aggregateIndex
index()
value.public abstract int index
Copyright © 2013-2018–2019 SeedStack. All rights reserved.