@Retention(value=RUNTIME) @Target(value=METHOD) public @interface MatchingFactoryParameter
fromFactory() method of the assembler DSL. If you don't use
this DSL feature, this annotated is unnecessary.
It binds the DTO's annotated method to one parameter of a factory method used to create the assembled aggregate.
It also handle the case of a DTO assembled from a tuple of aggregate roots.
Case 1: Basic use case.
public class CustomerDto {
@MatchingFactoryParameter(index = 0)
public String getName() {...}
@MatchingFactoryParameter(index = 1)
public Date getBirthDate() {...}
// No need for annotation here as the address is not part of the factory method
public Address getAddress() {...}
}
public class RecipeAssembler extends BaseAssembler<Customer, CustomerDto> { ... }
public class CustomerFactory {
public Customer createCustomer(String name, Date birthDate);
}
Case 2: The DTO is an assembly of multiple aggregates.
public class RecipeDto {
@MatchingFactoryParameter(index = 0, typeIndex = 0)
public String getCustomerName() {...}
@MatchingFactoryParameter(index = 1, typeIndex = 0)
public Date getCustomerBirthDate() {...}
@MatchingFactoryParameter(index = 0, typeIndex = 1)
public int getOrderId() {...}
}
public class RecipeAssembler extends BaseTupleAssembler<Pair<Customer, Order>, RecipeDto> { ... }
public class CustomerFactory {
Customer createCustomer(String name, Date birthDate);
}
public class OrderFactory {
Customer createOrder(int orderId);
}
public abstract int index
public abstract int typeIndex
BaseTupleAssemblerCopyright © 2013-2016–2016 SeedStack. All rights reserved.