It seems the need for a type like the following would be so ubiquitous that something like it should be already built into Java:
public interface Executer<T> {
void execute(T object);
}
It can then be used in other classes like this trivial example that calls a bunch of executers on an object.
class Handler<T> implements Executer<T> {
List<Executer<T>> executerList;
Handler(List<Executer<T>> executer) {
this.executerList = executer;
}
void execute(T t) {
for (Executer<T> executer : this.executerList) {
executer.execute(t);
}
}
}
Is there a built-in type equivalent or a common library equivalent? Is there a name for this concept?