Don't Repeat Yourself! Instead of hacking these lines again and again, just include this dependency and you're done!
As this JavaRanch article by Mark Spritzler  proofs, there seem to be some people that like to have a generic visitor pattern, so I decided to open source mine (LGPL), which lies around here on my disk for some time. Have fun using it, it is as simple as linking to:
A complete history of all my publications can be found on my web site Head Crashing Informatics .