I have this code:
public interface IDimension<S extends IDimension<S,T>, T extends Number> extends Comparable<S> {
T toNumber();
default T toBaseNumber() {
return toNumber();
}
S fromNumber( T units );
Class<T> numberType();
}
When I implement IDimension like below(Implementation1), I get 'Type parameter 'TestBaseSample' is not within its bound; should implement 'IDimension<TestBaseSample<Float,Integer>, java.lang.Long>' error:
Implementation1 :
class TestBaseSample<Integer, Float>
implements IDimension<TestBaseSample<Float, Integer>, Long> {
}
I understand why 'Implementation1' gives error, but not able to understand why 'Implementation2' and 'Implementation3' works?
Implementation2:
class TestBaseSample2<Integer, Float>
implements IDimension<TestBaseSample2<Float, Float>, Long> {
}
Implementation3 :
class TestBaseSample3<Integer, Float>
implements IDimension<TestBaseSample3<Integer, Integer>, Long> {
}
class TestBaseSample3<T, S>where T and S are generic types. ideone.com/Zq4AVt for example. Maybe you should change those to T & S so it is clear, or make them concrete.class TestBaseSample3 implements ...