Java generic class inheritance problem?

as shown in the title, you want to extend the properties by inheriting the GeoResult class

   //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{
 
    public GeoExtendResult(T content, Distance distance) {
        super(content, distance);
    }
}

//
List<GeoResult<RedisGeoCommands.GeoLocation<String>>> geoResultList =  radiusGeo.getContent();
//
List<GeoExtendResult<RedisGeoCommands.GeoLocation<String>>> geoResultList =  radiusGeo.getContent();



Mar.19,2021

I can see what you want to do, but there is something wrong with your description of the problem. Generics are characterized by generics. Let me give you an example.
for generic interfaces:

GeoExtendResult extends GeoResult<?> //
GeoExtendResult extends GeoResult<RedisDemo.GeoList<String>  // RedisDemo.GeoList<String> 

generic class:

GeoExtResult<T> extends GeoResult<T> //




third update:

public class GenericT<T> implements Serializable {

    private static final long serialVersionUID = 1637452570977581370L;
    private final T content;
    private final String distance;

    public GenericT(T content, String distance) {
        this.content = content;
        this.distance = distance;
    }
}


public class GenericExtT<T> extends GenericT<T> {

    public GenericExtT(T content, String distance) {
        super(content, distance);
    }

    public List<GenericExtT<T>> getContent() {
        return Collections.unmodifiableList(Lists.newArrayList());
    }

    @Autowired GenericExtT genericExtT;
    public void main(String[] args){
        //
        List<GenericExtT<? extends T>> geoResultList =  genericExtT.getContent();
    }

}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e467a3-4316a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e467a3-4316a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?