P
- the type of the produced object.@DomainFactory public interface Factory<P extends Producible>
A factory is part of the domain and responsible for creating some domain objects. In the
business framework a factory can only create domain objects implementing Producible
:
Note that non-root entities are not produced by factories but should be created by their aggregate root.
Being responsible for creating valid aggregates, factories may need to create their identity. This can be done
from input parameters given to the factory or by using an IdentityGenerator
.
Example:
public interface SomeFactory extends Factory<SomeAggregate> { SomeAggregate createFromName(String name); } public class SomeFactoryImpl implements SomeFactory { SomeAggregate createFromName(String name) { // create and return the aggregate } }
Modifier and Type | Method and Description |
---|---|
default P |
create(Object... args)
Creates an object instance in a generic way, using the given arguments.
|
Class<P> |
getProducedClass()
Returns the class produced by the factory.
|
Class<P> getProducedClass()
@Create default P create(Object... args)
args
- the arguments for object creation.Copyright © 2013-2018–2019 SeedStack. All rights reserved.