Interface EntityFactory<T>
- Type Parameters:
T- type of the entity
- All Known Subinterfaces:
EntityModel<T,U>
- All Known Implementing Classes:
DefaultEntityModel,DtoAwarePersistentEntityFactory,PersistentEntityFactory
public interface EntityFactory<T>
Interface that provides factory methods for creating a new entity instance,
or a DTO (detached) instance of an existing entity.
-
Method Summary
Modifier and TypeMethodDescriptionCreate a DTO of an existing entity.Create a new entity instance.static <T> EntityFactory<T>Create a defaultEntityFactorywhich uses theconstructorFunctionfor creating a new instance, and thedtoFunctionfor creating a DTO.static <T> EntityFactory<T>Create a defaultEntityFactorywhich uses thesupplierfor creating a new instance.static <T> EntityFactory<T>Create a defaultEntityFactorywhich uses thesupplierfor creating a new instance, and thedtoFunctionfor creating a DTO.
-
Method Details
-
createNew
Create a new entity instance. In case of anEntityFactoryfor an association, the first (and often only) argument will be the parent entity.- Parameters:
args- constructor arguments- Returns:
- new instance
-
createDto
Create a DTO of an existing entity.- Parameters:
entity- to create a DTO for- Returns:
- dto
-
of
Create a defaultEntityFactorywhich uses thesupplierfor creating a new instance. For creating a DTO that same supplier will be used to first create a new instance and then copy all public properties to the DTO.- Type Parameters:
T- entity type- Parameters:
supplier- for creating a new instance- Returns:
- factory
-
of
Create a defaultEntityFactorywhich uses thesupplierfor creating a new instance, and thedtoFunctionfor creating a DTO.- Type Parameters:
T- entity type- Parameters:
supplier- for creating a new instancedtoFunction- for creating a DTO- Returns:
- factory
-
of
static <T> EntityFactory<T> of(@NonNull @NonNull Function<Object[], T> constructorFunction, Function<T, T> dtoFunction) Create a defaultEntityFactorywhich uses theconstructorFunctionfor creating a new instance, and thedtoFunctionfor creating a DTO.- Type Parameters:
T- entity type- Parameters:
constructorFunction- for creating a new instancedtoFunction- for creating a dto- Returns:
- factory
-