A lot of my functions have a whole load of validation code just below the declarations:
if ( ! (start < end) ) {
throw new IllegalStateException( \"S
You might be able to do this with annotation and aspect orientated programming.
I would use IllegalArgumentException if an argument combination is not legal. I would use IllegalStateException is in a state which prevents the method from working.
You can create a helper method for the exception.
public static void check(boolean test, String message) {
if(!test) throw new IllegalArgumentException(message);
}
check(start < end, "Start must be before end.");