MichaelKohler/HelperTools — pull request #10 by MarkyV (2012-12-01 10:10:24+00:00)
Title: Added new Validator Class and Assert errors in private constructors

Hello,

This is my first pull request on github as inspired by http://24pullrequests.com/ and that was how I found this project. Please do provide feedback if this is an appropriate request and if I'm doing anything wrong, but I hope I am helping out here, so thanks!

Each of my separate commits and documentation go into more details, but basically, the ideas I am incorporating here are ingrained from my previous team's coding standards of rigorously preventing null pointer errors. My team used Google's Guava library (which are just awesome, check them out) to do Precondition (name of the class in Guava) checks on public arguments. Instead of bringing in a whole new dependency on Guava, I just added a "Validator" class that does the same concept and is much more light-weight. During our code reviews, these are items that we frequently comment on, so it's ingrained in me to always have code up to those standards.

This first pull request contains the new class as well as another (hopefully) improvement to throw IllegalArg in a private constructor. I at first thought it was a bit extreme as well, but thought I'd add it anyway as it's recommended in the "Effective Java" book Joshua Bloch as well as my former co-workers. My next upcoming request will contain the implementation of argument checks, which will prevent NullPointers from occurring and instead provide a more helpful error message as to what went wrong which helps speed up debugging a lot and various other advantages as explained here: https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained

Please let me know what you think and if this is acceptable, thanks