Can you handle a flagged value on hi(int x)
? If yes you could do something like this:
public void hi(int x) {
if (x == Integer.MIN_VALUE) {
String newParam = getTheParamFromProxySomehow();
hi(newParam);
return;
}
System.out.println("hi: " + x);
}
It is basically:
- Intercept through a proxy the
getBlah()
method - Save (in a
ThreadLocal
?) whatever String parameter you want to pass to the overloadedhi
method - Return the flagged value such as
0
,-1
orInteger.MIN_VALUE
- Do the trick above
It is a little hacky and it looks best when you don't have a primitive so you can use null
as your flagged value. Hopefully someone has a better answer. :)