dk.apaq.crud.Crud Maven / Gradle / Ivy
/*
* CrudContainer
* Copyright (C) 2011 by Apaq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package dk.apaq.crud;
import dk.apaq.filter.Filter;
import dk.apaq.filter.limit.Limit;
import dk.apaq.filter.sort.Sorter;
import java.util.List;
/**
* An Interface for a Crud. The interface is split into several interfaces allowing
* for Crud's to only implement some methods fx. for readonly cruds.
*
* If more functionality is required, fx. update, create, delete or filtering, then
* the cruds need to implement the subinterfaces.
* @param The type used as Id for the entity, fx. String.
* @param The entity type.
*/
public interface Crud {
/**
* Reads a single enntity by its id.
* @param id The id of the entity to read.
* @return Returns the entity or null if entity available with the specified id.
*/
T read(IDT id);
/**
* Lists all id's.
* @return The list of all id's
*/
List listIds();
/**
* List all items. This method is potentially very resource consuing as it will
* return all complete objects maintained by the crud.
* @return The list of all objects.
*/
List list();
/**
* Lists all id's.
* @param limit Limits the returned result
* @return The list of all id's
*/
List listIds(Limit limit);
/**
* List all items with a limit.
* @return The list of all objects.
*/
List list(Limit limit);
/**
* Interface for editable cruds.
* @param The type used as Id for the entity, fx. String.
* @param The entity type.
*/
public interface Editable extends Crud {
IDT create();
IDT create(T entity);
void update(BT entity);
void delete(IDT id);
}
/**
* Interface for filterable cruds.
* @param The type used as Id for the entity, fx. String.
* @param The entity type.
*/
public interface Filterable extends Crud {
List listIds(Filter filter, Sorter sorter);
List listIds(Filter filter, Sorter sorter, Limit limit);
List list(Filter filter, Sorter sorter);
List list(Filter filter, Sorter sorter, Limit limit);
}
/**
* Interface for cruds that implements all crud methods.
* @param The type used as Id for the entity, fx. String.
* @param The entity type.
*/
public interface Complete extends Filterable, Editable { }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy