Java Generic of Another generic

Viewed 184

I have interface:

interface Identifable<T extends Serializable> {
      T getID();
}

and class that implement this:

public class Cat implements Identifable<Long> {
       public Long getID(){...};
}

everything works fine. so far. Now I want to create GenericDAO, why I cannot create this?:

public abstract GenericDAO<T extends Identifable<S>> {
    T getByID(S id);
}

I can only declare my GenericDAO as this:

public abstract GenericDAO<T extends Identifable, S> {
  T getById(S id);
}

And complete class:

public CatDAO extends GenericDAO<Cat, Long> {
      Cat getById(Long id);
}

But i think it's useless, because I repeat information. I already declared, that Cat implements Identifable< Long >, so why do I must declare GenericDAO< Cat, Long >, not just GenericDAO< Cat > ?

2 Answers
Related