I use that pattern to embed multiple tiny concrete implementations that share a large amount of commonality. It's easier to manage 25 tiny extensions of the same abstract class within the same file. Using like in C# namespace enclosure.
/**
* Dao 道 = access/way/avenue
* Bao 包 = bundle/package/
*/
public interface DaoBao {
public abstract class <E extends BlessedEntity> BlessedDaoWager<E,T> {
private JdbcTemplate jtmpl;
public void setDatasource(Datasource ds) {
this.jtmpl = new JdbcTemplate(ds);
}
public E find(BlessedKey key) {
blah .. blah .. blah ...
}
public List<E> list(Date from, Date to) {
blah .. blah .. blah ...
}
public boolean remove(BlessedKey key) {
blah .. blah .. blah ...
}
public T getKey(E ent) {
return ent.getId();
}
}
public class BlessedEmployeeDao
extends BlessedDaoWager<BlessedEmployeeEntity, Long> {
public Long getKey(BlessedEmployeeEntity ent) {
return ent.getCucurucucu();
}
}
public class BlessedSalaryDao
extends BlessedDaoWager<BlessedSalaryEntity, BlessedEmployeeEntity> {
public BlessedEmployeeEntity getKey(BlessedSalaryEntity ent) {
return ent.getEmployeeId();
}
}
public class BlessedHoursDao
extends BlessedDaoWager<BlessedHoursEntity, BlessedEmployeeEntity> {
public BlessedEmployeeEntity getKey(BlessedSalaryEntity ent) {
return ent.getEID();
}
}
public class BlessedGooDao
extends BlessedDaoWager<BlessedGooEntity, String> {
public String getKey( ent) {
return ent.getName();
}
}
public class BlessedHowDao extends BlessedDaoWager<BlessedEntity, Long> {}
public class BlessedNowDao extends BlessedDaoWager<BlessedEntity, Date> {}
}
There are those who say, what if someone inadvertently implemented the interface. I would say those are inadvertent programmers looking for ways to prevent their inadvertent programming habits.