The Unannoyment library provides a simple precondition mechanism so that you will program more defensively in Java.
Wasn't this code a royal pain in the butt to write?
if (arg == null) { String error = "In function 'func', argument 'arg' was null"; throw new IllegalArgumentException(error); } if (str == null) { String error = "In function 'func', argument 'str' was null"; throw new IllegalArgumentException(error); } else if (str == null) { String error = "In function 'func', argument 'str' was empty"; throw new IllegalArgumentException(error); }With Unannoyment, you say something far simpler:
ArgCheck.notNull("func", "arg", arg); ArgCheck.notNullOrEmpty("func", "str", str);ArgCheck provides these two simple cases, but it is also extensible for creating other preconditions.
if (str != null && str.length() > 0)... if (str == null || str.length() == 0)...We alse provide a String helper class which helps you produce more readable code:
if (Str.notNullOrEmpty(str))... if (Str.nullOrEmpty(str))...
The idea here is to replace something which normally takes 3 or 4 lines of code with one very short line. This sounds pretty trivial they are checks which should happen very frequently. Either people clutter up their code with these checks, or they leave them out and the bugs in their code is harder to track down. Using our library makes the checks so easy to perform, they have no longer any excuse not to use them.
This is if you want the cutting-edge (read: broken) stuff. If you want to improve Unannoyment, we would more than welcome your contribution. Send me an email (kow at loria point fr), and i will add you to the developer list.
Unannoy comes with everything it needs (i.e. nothing). You can use it as a library for all your Java projects.