So, I have this abstract class that represents an Input type object -
public abstract class Input<E> And I have two classes that extends it, one is ButtonInput and the other is TextInput. Both extend Input so it doesn't really matter. I'll use TextInput just to explain.
This is the TextInput class defention:
public class TextInput extends Input<TextInput> What I'm trying to do is to return this as E (TextInput in this case)-
public E setTextColor(Color color) { this.colorText = color; return (E)this; } So, If I call for example:
new TextInput().setColor(Color.black) It should return TextInput. It is working but, it shows the following warning -
warning: [unchecked] unchecked cast
return (E) this; required: E
found: Input
where E is a type-variable:
E extends Object declared in class Input
In relation to the following line of code -
return (E) this; Does anybody knows how to solve it?
Thanks
<E extends Input>for the method, E is already parametrised.