Can I have an annotation for a method that when its parameters are null, just do nothing, effectively as not being invoked?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Probably the easiest way to do this is using interfaces and dynamic proxies. Annotations do nothing other than add metadata. You’re going to have to add code to act based on the annotation.
You’d have to do a few things —
Create an interface
When using the implementation, instantiate it as a JDK Proxy.
Now, you can via reflection, capture all invocations of your method in
YourProxyclass.If you dont want to do this, then you’re looking at more heavyweight frameworks such as AspectJ / Spring AOP.