Interface ApiCrudMixin


  • public interface ApiCrudMixin
    Mixin to simplify CRUD (create-read-update-delete) operations on entities implemented via the Configuration.ApiProvider layer .
    Since:
    8.0.0
    Author:
    XIMA MEDIA GmbH
    • Method Detail

      • create

        default <T extends ITransferableEntity> T create​(T entity)
        Creates the given non-persisted entity.
        Type Parameters:
        T - Type of the entity.
        Parameters:
        entity - Entity to create.
        Returns:
        The created entity.
      • createOrUpdate

        default <T extends ITransferableEntity> T createOrUpdate​(T entity)
        Creates the given entity if not yet persisted, or updates it otherwise.
        Type Parameters:
        T - Type of the entity.
        Parameters:
        entity - Entity to create or update.
        Returns:
        The created or updated entity.
      • delete

        default void delete​(ITransferableEntity entity)
        Delete the given entity.
        Parameters:
        entity - Entity to delete.
      • uc

        UserContext uc()
        Returns:
        The user context to use for API operations.
      • read

        default <T extends ITransferableEntity> T read​(Class<T> type,
                                                       de.xima.cmn.criteria.FilterCriterion filters)
        Reads the entity with the given filter.
        Type Parameters:
        T - Type of the entity.
        Parameters:
        type - Type of the entity to read.
        filters - Filters to apply to the search for the entity.
        Returns:
        The single entity matching the given filter, or null if no entity matches.
        Throws:
        IllegalStateException - When more than one entity matches the given filters.
        See Also:
        , for creating complex filters.
      • read

        default <T extends ITransferableEntity> T read​(Class<T> type,
                                                       long id)
        Read the entity with the given database ID.
        Type Parameters:
        T - Type of the entity.
        Parameters:
        type - Type of the entity to read.
        id - ID of the entity.
        Returns:
        The read entity, or null if no such entity exists.
      • readAll

        default <T extends ITransferableEntityList<T> readAll​(Class<T> type,
                                                                de.xima.cmn.criteria.FilterCriterion filters)
        Reads the entity with the given filter.
        Type Parameters:
        T - Type of the entity.
        Parameters:
        type - Type of the entity to read.
        filters - Filters to apply to the search for the entity.
        Returns:
        A list of all entities matching the given filter.
        See Also:
        , for creating complex filters.
      • update

        default <T extends ITransferableEntity> T update​(T entity)
        Update the given existing entity.
        Type Parameters:
        T - Type of the entity.
        Parameters:
        entity - Entity to update.
        Returns:
        The updated entity.