Class AbstractSelectService<Entity,Model,SelectOption extends AbstractSelectOption,SelectRepository extends org.springframework.data.repository.CrudRepository<Entity,Long>>
java.lang.Object
fr.tiogars.architecture.select.services.AbstractSelectService<Entity,Model,SelectOption,SelectRepository>
- Type Parameters:
Entity- the type of entityModel- the type of modelSelectOption- the type of select optionSelectRepository- the type of repository
public abstract class AbstractSelectService<Entity,Model,SelectOption extends AbstractSelectOption,SelectRepository extends org.springframework.data.repository.CrudRepository<Entity,Long>>
extends Object
Abstract class for select services that provides a common structure
for selecting entities and converting them to models.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe repository used for pagination and sorting operations. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSelectService(SelectRepository repository) Constructor to initialize the repository. -
Method Summary
Modifier and TypeMethodDescriptionselect(SelectRequest request) Select entities based on the provided request and convert them to select options.abstract ModelConvert an entity to a model.abstract SelectOptiontoSelectOptions(Model model) Convert a model to a select option.
-
Field Details
-
repository
public SelectRepository extends org.springframework.data.repository.CrudRepository<Entity,Long> repositoryThe repository used for pagination and sorting operations.
-
-
Constructor Details
-
AbstractSelectService
Constructor to initialize the repository.- Parameters:
repository- the repository used for pagination and sorting operations
-
-
Method Details
-
toModel
Convert an entity to a model.- Parameters:
entity- the entity to convert- Returns:
- the converted model
-
toSelectOptions
Convert a model to a select option.- Parameters:
model- the model to convert- Returns:
- the converted select option
-
select
Select entities based on the provided request and convert them to select options.- Parameters:
request- the select request containing search criteria- Returns:
- a select response containing the list of select options
-