I have a use-case where the return behaviour of the callee method should change based on the annotation of the caller method.
Here is the situation:
@SomeAnnotation
public void caller(){
return SomeOtherClass.caller(String arg);
}
// Returns X in this case
public class SomeOtherClass{
public String callee(String arg){
if(annotationIsPresent(SomeAnnotation.class))
return "X";
else
return "Y";
}
}
I went through some resources and I found this.
I was thinking of using Thread.currentThread().getStackTrace()
to get the current invoker method.
I have no clue if this is feasible or is a correct design also. Could someone please comment on it?
Aucun commentaire:
Enregistrer un commentaire