我提供了一个GroupDao界面示例。
public interface GroupDao {
void add(Group group);
List<Group> getGroupsList();
void update(Group group);
Group findById(Long groupId);
void delete(Long groupId);
}
我想将其合并为一个界面,例如
public interface EntitiesDao {
void add({generic} entity);
List<{generic}> getList();
void update({generic} entity);
{generic} findById(Long entityId);
void delete(Long entityId);
}
我该怎么做?预先感谢
答案 0 :(得分:3)
为此,您应该使用泛型。
public interface EntitiesDao<T>
{
void add(T entity);
List<T> getList();
void update(T entity);
T findById(Long entityId);
void delete(Long entityId);
}