Redundant generic parameters

后端 未结 6 1912
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 03:36

I have this two interfaces and classes:

public interface Identifiable {
    T getId();
}

public interface GenericRepository

        
6条回答
  •  遥遥无期
    2021-01-12 04:16

    Not much you can do, other than introduce an interface that just refines GenericRepository

      public interface LongKeyedRepository> 
            extends GenericRepository { {
      //No new methods need to be defined
      }
    

    Then you can have

    private LongKeyedRepository myEntityRepository;
    

    etc.

提交回复
热议问题