Interface EntityModel<T,U extends Serializable>
- Type Parameters:
T
- entity typeU
- id type of the entity
- All Superinterfaces:
EntityFactory<T>
,org.springframework.data.repository.core.EntityInformation<T,
,U> org.springframework.data.repository.core.EntityMetadata<T>
- All Known Implementing Classes:
DefaultEntityModel
public interface EntityModel<T,U extends Serializable>
extends org.springframework.data.repository.core.EntityInformation<T,U>, EntityFactory<T>
Interface for accessing metadata and common entity functions that are required by the basic UI.
A model is required for an entity to be manageable through the UI.
- Author:
- Arne Vandamme
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionConvert an existing entity into a dto.Create a new instance of the entity type this model represents.void
Deletes the given entity.Find a single entity based on its unique id.Generates a label for the entity and the default locale attached to the thread.Generates a label for the entity and the locale specified.Saves an entity.Methods inherited from interface org.springframework.data.repository.core.EntityInformation
getId, getIdType, getRequiredId, isNew
Methods inherited from interface org.springframework.data.repository.core.EntityMetadata
getJavaType
-
Method Details
-
getLabel
Generates a label for the entity and the default locale attached to the thread.- Parameters:
entity
- to generate the label for- Returns:
- label
-
getLabel
Generates a label for the entity and the locale specified.- Parameters:
entity
- to generate the label forlocale
- to use for formatting- Returns:
- label
-
createNew
Create a new instance of the entity type this model represents. Optionally a number of arguments can be passed, however for basic entity views the model should support a new instance without any arguments.- Specified by:
createNew
in interfaceEntityFactory<T>
- Parameters:
args
- optional list of arguments (eg. constructor parameters)- Returns:
- newly created entity
-
createDto
Convert an existing entity into a dto. Used by default views to ensure operations are not done on managed entities.- Specified by:
createDto
in interfaceEntityFactory<T>
- Parameters:
entity
- to convert into a dto- Returns:
- dto of the entity
-
findOne
Find a single entity based on its unique id.- Parameters:
id
- of the entity- Returns:
- entity or null if not found
-
save
Saves an entity. Depending on the entity information this will perform an update or a create. The return value depends on the implementation but in default cases the entity passed in will be detached (dto) and the return value will be the managed entity.- Parameters:
entity
- to save- Returns:
- saved entity
-
delete
Deletes the given entity.- Parameters:
entity
- to delete
-