的,我有以下接口:接口方法采取相同的实现接口
public interface ClusterPopulation
{
public double computeDistance(ClusterPopulation other);
}
是否有可能接口本身内指定,ClusterPopulation的是实现一个只能拿一个实现作为computeDistance的说法?
唯一approching的解决方案,我看到的是下面的,但我不喜欢它:
泛型接口重新定义:
public interface ClusterPopulation
{
public <T extends ClusterPopulation> double computeDistance(T other);
}
内执行,抛出IllegalArgumentException如果从参数不好的类型,如果类型没问题的话可以做一些演员...... Meeeeh!
即使使用这种方法,最终用户只知道约束的阅读文档/查看代码执行/试错...
任何更好的解决方案?
http://stackoverflow.com/questions/7354740/is-there-a-way-to-refer-to-the-current-type-with-a-type-variable – biziclop