A lot of my functions have a whole load of validation code just below the declarations:
if ( ! (start < end) ) {
throw new IllegalStateException( \"S
Guava's Preconditions class is just for this. You typically use it with static imports, so your example would look like:
checkArgument(start < end, "Start must be before end");
It makes it easy to add more information to the message as well, without paying the cost of String concatenation if the check passes.
checkArgument(start < end, "Start (%s) must be before end (%s)", start, end);
Unlike assert statements, these can't be disabled.