Skip to content

Instantly share code, notes, and snippets.

@heat
Created November 5, 2014 14:51
Show Gist options
  • Save heat/1e79329d01587df09cc4 to your computer and use it in GitHub Desktop.
Save heat/1e79329d01587df09cc4 to your computer and use it in GitHub Desktop.
Exemplo de um repositorio de entidade pro java de uma entidade agregadora
public interface EntityRepository<K, E> {
/*
* Para uma base de dados multi-clientes
*/
public List<E> todos(Integer id);
public E busca(K key);
public K inserir(E entity);
public void atualizar(K key, E entity);
public void excluir(K key);
/*
* Quando uma entidade é um agregador ele
* retornara podera interar sobre uma "lista" dos elementos de sua
* responsabilidade
*/
public ObjectRepository<KeyOject, ObjectElem> of(K key);
public static interface ObjectRepository<V, O> {
public V add(O object);
public void remove(K key);
public List<O> list();
public O get(V k);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment