如题所示,想通过继承GeoResult类来扩展属性//GeoResult 类
public class GeoResult<T> implements Serializable {
private static final long serialVersionUID = 1637452570977581370L;
private final T content; private final Distance distance;
public GeoResult(T content, Distance distance) {
Assert.notNull(content, "Content must not be null!");
Assert.notNull(distance, "Distance must not be null!");
this.content = content;
this.distance = distance;
}
}
//扩展GeoResult类
public class GeoExtendResult<T> extends GeoResult<T> implements Serializable{
private String str;
public GeoExtendResult(T content, Distance distance, String str) {
this.str = "abc";
super(content, distance);
}
public String getStr() {
return str;
}
public void setStr(String str) {
this.str = str;
}
}
//这是正确的
List<GeoResult<RedisGeoCommands.GeoLocation<String>>> geoResultList = radiusGeo.getContent();
//报类型不匹配
List<GeoExtendResult<RedisGeoCommands.GeoLocation<String>>> geoResultList = radiusGeo.getContent();
添加回答
举报
0/150
提交
取消