I try to create this class:
public class Class1<T extends Class2<E>> {
...
public E someFunction(T param) {
...
}
...
}
I saw topic [blog]: Java class with 2 generic parameters and in it topic suggest using this solution:
public class Class1<T extends Class2<E extends Class3>, E extends Class3> {
...
public E someFunction(T param) {
...
}
...
}
It is works, but in this case I should using 2 parameters without one:
Class1<Class21<Class31>, Class31> var = ...
In this solution I duplicate class 'Class31'. Has this task have more simple solution, to using following code:
Class1<Class21<Class31>> var = ...
Update1:
What problem are you trying to solve?
For example, I have class for images. Images can be single-channel (gray image) and multi-channel (3 channels for RGB, HSB and etc. or 4 channels or RGB and etc. + Alpha channel). Also, image can save value RGB in byte 0..255 or in float (0.0, 1.0) and it is different type of images. So, I want to create class for this images and construct it as:
MyImage<MyChannelType3<MyColorTypeInt>> img1 = ...
MyImage<MyChannelType3<MyColorTypeFloat>> img2 = ...
MyImage<MyChannelType1<MyColorTypeFloat>> img3 = ...
and have access to colors in pixel as:
int Red = img1.getPixel(x, y)[0];
float Green = img2.getPixel(x, y)[0];
float Gray = img3.getPixel(x, y);
I think is more useful than:
MyImage<MyChannelType3<MyColorTypeInt>> img1 = ...
int Red = img1.getPixel(x, y).getChannel(0).getValue();
If I will be firs return MyChannelType3, than MyColorTypeInt and then value or return Object and demand casting it to int, float, int[] or float[].
Class1<Class21,Class31> var, if you're using the form suggested in the blog.