I often find myself wanting to just print (using the implicit toString() of each object) every argument to a method in Java. Is there a quick way of accomplishing this?
Java programming language doesn't have a construct to do this. However, you can do it with one of the AOP (Aspect Oriented Programming) packages, such as AspectJ.
In particular this thread might be a good starting point on how to achieve this:
http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg09939.html
My personal opinion, however, is that most of the time AOP is a scary overkill.
UPDATE: Oh, here's an easier way using Spring AOP, assuming you can use Spring. Generally, Spring is much easier to use than pure AspectJ.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With