Class EntityModelBuilder<T>
java.lang.Object
com.foreach.across.modules.entity.config.builders.EntityModelBuilder<T>
Builder to create a new
DefaultEntityModel
or modify an existing one.- Since:
- 2.0.0
- Author:
- Arne Vandamme
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionand
(@NonNull Consumer<EntityModelBuilder<T>> consumer) Apply an additional consumer to this builder.void
apply
(DefaultEntityModel<T, Serializable> model) Modify an existingDefaultEntityModel
.build()
Create a new model.deleteByIdMethod
(Consumer<Serializable> deleteMethodById) Set the method callback based on the unique id of the entity.deleteMethod
(Consumer<T> deleteMethod) Set the method callback for deleting an entity.entityFactory
(EntityFactory<T> entityFactory) Set theEntityFactory
for this model.entityInformation
(org.springframework.data.repository.core.EntityInformation<?, ?> entityInformation) Set theEntityInformation
for this model.findOneMethod
(Function<Serializable, T> findOneMethod) Set the method callback for finding a single entity by id.labelPrinter
(Function<T, String> labelFunction) Set the label printer for this model as a function.labelPrinter
(org.springframework.format.Printer<T> labelPrinter) Set the label printer for this model.saveMethod
(UnaryOperator<T> saveMethod) Set the method callback for saving an entity.
-
Constructor Details
-
EntityModelBuilder
public EntityModelBuilder()
-
-
Method Details
-
entityFactory
Set theEntityFactory
for this model.- Parameters:
entityFactory
- to set- Returns:
- current builder
-
entityInformation
public EntityModelBuilder<T> entityInformation(org.springframework.data.repository.core.EntityInformation<?, ?> entityInformation) Set theEntityInformation
for this model.- Parameters:
entityInformation
- to set- Returns:
- current builder
-
labelPrinter
Set the label printer for this model as a function.- Parameters:
labelFunction
- to use as- Returns:
- current builder
-
labelPrinter
Set the label printer for this model.- Parameters:
labelPrinter
- to set- Returns:
- current builder
-
findOneMethod
Set the method callback for finding a single entity by id.- Parameters:
findOneMethod
- callback method- Returns:
- current builder
-
saveMethod
Set the method callback for saving an entity.- Parameters:
saveMethod
- callback method- Returns:
- current builder
-
deleteMethod
Set the method callback for deleting an entity.- Parameters:
deleteMethod
- callback method- Returns:
- current builder
-
deleteByIdMethod
Set the method callback based on the unique id of the entity. Will automatically convert into an entity based delete method that uses theEntityModel
itself to lookup the id of the entity. Will only be used if the builder was not called withdeleteMethod(Consumer)
.- Parameters:
deleteMethodById
- callback method- Returns:
- current builder
-
and
Apply an additional consumer to this builder.- Parameters:
consumer
- to apply- Returns:
- current builder
-
build
Create a new model.- Returns:
- newly created model
-
apply
Modify an existingDefaultEntityModel
.- Parameters:
model
- to be customized with the builder settings
-