I\'m experimenting with this code:
interface Callee {
public void foo(Object o);
public void foo(String s);
public void foo(Integer i);
}
class
Ability to dispatch a call to a method based on types of arguments is called multiple dispatch. In Java this is done with Visitor pattern.
However, since you're dealing with Integer
s and String
s, you cannot easily incorporate this pattern (you just cannot modify these classes). Thus, a giant switch
on object run-time will be your weapon of choice.