I have an abstract class that creates a new instance of another class. In that class I create another object and need to modify that object based on the interfaces implementing class (abstract class's subclasses). I'm not sure if I'm waaaaaay overcomplicating this. And foremost would like to know if what I'm doing here considered reflection?
So for example:
interface MyInterface {
modifySomeObject(SomeObject obj);
}
class AbstractClassA implements MyInterface {
AbstractClassA() {
SomeClassC c = new SomeClassC(this);
}
}
class SomeClassC {
SomeClassC(MyInterface interface) {
SomeObject obj = new SomeObject();
interface.modifySomeObject(obj);
}
}
class SubclassX extends AbstractClassA implements MyInterface {
Override
modifySomeObject(SomeObject obj) {
obj.doModificationX();
}
}
class SubclassY extends AbstractClassA implements MyInterface {
Override
modifySomeObject(SomeObject obj) {
obj.doModificationY();
}
}
Aucun commentaire:
Enregistrer un commentaire