Delegation (Java)

Sunday, July 6, 2014

This example is taken from Thinking in Java book.



class FilterAdapter implements Processor {
Filter filter;
public FilterAdapter(Filter filter) {
this.filter = filter;
}
public String name() { return filter.name(); }
public Waveform process(Object input) {
return filter.process((Waveform)input);
}
}


Then when this piece of code is scrutinized, the authors draws our attention to the fact that we may notice delegation in the FilterAdapter class.


Could you help me understand what is meant. I have read this code 30 times and can't see anything particular. According to Wikipedia, "delegation refers to one object relying upon another to provide a specified set of functionalities". Well, I can't find anything like this here. Your help would be highly appreciated.







http://ift.tt/1vN6hw9