Class EntityModelBuilder<T>

java.lang.Object
com.foreach.across.modules.entity.config.builders.EntityModelBuilder<T>

public class EntityModelBuilder<T> extends Object
Builder to create a new DefaultEntityModel or modify an existing one.
Since:
2.0.0
Author:
Arne Vandamme
See Also:
  • Constructor Details

    • EntityModelBuilder

      public EntityModelBuilder()
  • Method Details

    • entityFactory

      public EntityModelBuilder<T> entityFactory(EntityFactory<T> entityFactory)
      Set the EntityFactory for this model.
      Parameters:
      entityFactory - to set
      Returns:
      current builder
    • entityInformation

      public EntityModelBuilder<T> entityInformation(org.springframework.data.repository.core.EntityInformation<?,?> entityInformation)
      Set the EntityInformation for this model.
      Parameters:
      entityInformation - to set
      Returns:
      current builder
    • labelPrinter

      public EntityModelBuilder<T> labelPrinter(Function<T,String> labelFunction)
      Set the label printer for this model as a function.
      Parameters:
      labelFunction - to use as
      Returns:
      current builder
    • labelPrinter

      public EntityModelBuilder<T> labelPrinter(org.springframework.format.Printer<T> labelPrinter)
      Set the label printer for this model.
      Parameters:
      labelPrinter - to set
      Returns:
      current builder
    • findOneMethod

      public EntityModelBuilder<T> findOneMethod(Function<Serializable,T> findOneMethod)
      Set the method callback for finding a single entity by id.
      Parameters:
      findOneMethod - callback method
      Returns:
      current builder
    • saveMethod

      public EntityModelBuilder<T> saveMethod(UnaryOperator<T> saveMethod)
      Set the method callback for saving an entity.
      Parameters:
      saveMethod - callback method
      Returns:
      current builder
    • deleteMethod

      public EntityModelBuilder<T> deleteMethod(Consumer<T> deleteMethod)
      Set the method callback for deleting an entity.
      Parameters:
      deleteMethod - callback method
      Returns:
      current builder
    • deleteByIdMethod

      public EntityModelBuilder<T> deleteByIdMethod(Consumer<Serializable> deleteMethodById)
      Set the method callback based on the unique id of the entity. Will automatically convert into an entity based delete method that uses the EntityModel itself to lookup the id of the entity.

      Will only be used if the builder was not called with deleteMethod(Consumer).

      Parameters:
      deleteMethodById - callback method
      Returns:
      current builder
    • and

      public EntityModelBuilder<T> and(@NonNull @NonNull Consumer<EntityModelBuilder<T>> consumer)
      Apply an additional consumer to this builder.
      Parameters:
      consumer - to apply
      Returns:
      current builder
    • build

      public EntityModel<T,Serializable> build()
      Create a new model.
      Returns:
      newly created model
    • apply

      public void apply(DefaultEntityModel<T,Serializable> model)
      Modify an existing DefaultEntityModel.
      Parameters:
      model - to be customized with the builder settings