Interface EntityModel<T,U extends Serializable>

Type Parameters:
T - entity type
U - 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 Type
    Method
    Description
    createDto(T entity)
    Convert an existing entity into a dto.
    createNew(Object... args)
    Create a new instance of the entity type this model represents.
    void
    delete(T entity)
    Deletes the given entity.
    findOne(U id)
    Find a single entity based on its unique id.
    getLabel(T entity)
    Generates a label for the entity and the default locale attached to the thread.
    getLabel(T entity, Locale locale)
    Generates a label for the entity and the locale specified.
    save(T entity)
    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

      String getLabel(T entity)
      Generates a label for the entity and the default locale attached to the thread.
      Parameters:
      entity - to generate the label for
      Returns:
      label
    • getLabel

      String getLabel(T entity, Locale locale)
      Generates a label for the entity and the locale specified.
      Parameters:
      entity - to generate the label for
      locale - to use for formatting
      Returns:
      label
    • createNew

      T createNew(Object... args)
      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 interface EntityFactory<T>
      Parameters:
      args - optional list of arguments (eg. constructor parameters)
      Returns:
      newly created entity
    • createDto

      T createDto(T entity)
      Convert an existing entity into a dto. Used by default views to ensure operations are not done on managed entities.
      Specified by:
      createDto in interface EntityFactory<T>
      Parameters:
      entity - to convert into a dto
      Returns:
      dto of the entity
    • findOne

      T findOne(U id)
      Find a single entity based on its unique id.
      Parameters:
      id - of the entity
      Returns:
      entity or null if not found
    • save

      T save(T entity)
      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

      void delete(T entity)
      Deletes the given entity.
      Parameters:
      entity - to delete