package md.expertsystem.core.service;

import java.util.List;

import md.expertsystem.core.entities.ESCoreEntity;

/**
 * <p>
 * Parent for all service interfaces, with common {@code CRUD} methods.
 * </p>
 * 
 * @author Valentin Nastasi
 *
 */
public interface GenericService {

	/**
	 * <p>
	 * Retrieves a persistent entity by its ID.
	 * </p>
	 * 
	 * @param entityClassType
	 *            class type of the persistent entity
	 * @param id
	 *            the value of the primary key (ID)
	 * @return an instance of a persistent entity class type
	 */
	<E extends ESCoreEntity> E getItem(Class<E> entityClassType, Long id);

	/**
	 * <p>
	 * Retrieves all persistent entities of a given type.
	 * </p>
	 * 
	 * @param entityClassType
	 *            class type of the persistent entity
	 * @return a list of persistent entity class type instances
	 */
	<E extends ESCoreEntity> List<E> getItemList(Class<E> entityClassType);

	/**
	 * <p>
	 * Inserts a new persistent entity.
	 * </p>
	 * 
	 * @param entity
	 *            the entity to insert
	 */
	<E extends ESCoreEntity> void save(E entity);

	/**
	 * <p>
	 * Updates an existing persistent entity.
	 * </p>
	 * 
	 * @param entity
	 *            the entity to update
	 */
	<E extends ESCoreEntity> void update(E entity);

	/**
	 * <p>
	 * Deletes an existing persistent entity.
	 * </p>
	 * 
	 * @param entity
	 *            the entity to delete
	 */
	<E extends ESCoreEntity> void delete(E entity);

}
