Here is the situation. I have a 3rd party class
public class Client {
void kill();
}
I need my factory to return a modified version of this client where kill() does nothing (so that in future people don't accidentally break stuff). But I also need to be able to kill() when needed. Since this is a 3rd party library, I don't have access to modify the client. How can I make this work?
Part a of the problem is simple, I just have to extend Client:
void getClient() {
return new Client() {
@Override
public void kill() {
//do nothing
}
}
}
Part b, ie, saving the actions of the original parent kill() method is tricky and that's where I need help. Thanks
Aucun commentaire:
Enregistrer un commentaire