鉴于:
public interface PrimaryKey<Key extends Comparable> {
Key getKey();
}
和
public class PrimaryKeyComparator implements Comparator<PrimaryKey> {
public int compare(PrimaryKey first, PrimaryKey second) {
return first.getKey().compareTo(second.getKey());
}
}
这种组合有效,但会发出有关原始类型的警告。我尝试了各种添加类型参数的方法,但我尝试的每种组合都会破坏代码。