I have an interface hierarchy similar to –
interface Type
{
Type copy();
};
interface SubType extends Type
{
};
interface SubSubType extends SubType
{
};
And a concrete class
public class Concrete implements SubSubType
{
@Override public Concrete copy() { return new Concrete(); }
}
I would like to be able to call copy() on a Type and get a Type back, call copy() on a SubType and get a SubType back, etc. Is this achievable? Possibly with generics?
Thanks in advance.
Like so: