I have the following three classes:
public class MyClassA extends FooA<Bar>
public class MyClassB extends FooB<Bar>
public class MyClassC extends FooC<Bar>
The classes FooA, FooB and FooC all extend Foobar<V> (-> public class Foobar<V extends FooY> implements IFoobar<V>) but at different inheritance levels. Furthermore, it is worth mentioning that FooA, FooB and FooC are part of an API, which I am not able to modify. In my classes MyClassA, MyClassB and MyClassC, I am using some properties and methods in the exact same way and as a consequence I want to create a parent class which implements this same behavior. However, I am not sure how I can implement this inheritance scenario via generics.
I thought about something like:
public class MyParentClass<V extends Foobar> extends V
And then I would simply do the following:
public class MyClassA extends MyParentClass<FooA<Bar>>
public class MyClassB extends MyParentClass<FooB<Bar>>
public class MyClassC extends MyParentClass<FooC<Bar>>
How can I make this work?
Aucun commentaire:
Enregistrer un commentaire