
fr.zebasto.spring.identity.contract.service.CrudService Maven / Gradle / Ivy
package fr.zebasto.spring.identity.contract.service;
import java.io.Serializable;
import java.util.Set;
/**
* Description of the service that manages an entity
*
* @param The parametrized type used to define the entity
* @param The parametrized type used to identify an entity {@link Serializable}
* @author Bastien Cecchinato
* @since 1.0.0
*/
public interface CrudService {
/**
* Create new resource.
*
* @param resource Resource to create
* @return new resource
* @since 1.0.0
*/
T create(T resource);
/**
* Update existing resource.
*
* @param resource Resource to update
* @return resource updated
* @since 1.0.0
*/
T update(T resource);
/**
* Delete existing resource.
*
* @param resource Resource to delete
* @since 1.0.0
*/
void delete(T resource);
/**
* Delete existing resource.
*
* @param id Resource id
* @since 1.0.0
*/
void delete(I id);
/**
* Delete all existing resource. Do not use cascade remove (not a choice ie. JPA specs)
*
* @since 1.0.0
*/
void deleteAll();
/**
* Delete all existing resource, including linked entities with cascade delete
*
* @since 1.0.0
*/
void deleteAllWithCascade();
/**
* Find resource by id.
*
* @param id Resource id
* @return resource
* @since 1.0.0
*/
T findById(I id);
/**
* Find resources by their ids.
*
* @param ids Resource ids
* @return a list of retrieved resources, empty if no resource found
* @since 1.0.0
*/
Iterable findByIds(Set ids);
/**
* Find all resources.
*
* @return a list of all resources.
* @since 1.0.0
*/
Iterable findAll();
/**
* Count all resources.
*
* @return number of resources
* @since 1.0.0
*/
Long count();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy