danielferber/infra4j — Issue #2: Turn IllegalControlStateExceptions into static class
Author: danielferber
Created: 2012-01-20 17:33:30+00:00
State: open

I propose to turn IllegalControlStateExceptions into a class of static methods. The exception would be a public static inner class.

Reason 1: Applying assertions with IllegalControlStateExceptions is quite verbose. I propose a shorter notation.
Instead of:
assert IllegalDataStateException.apply(Rules.ruleA, condition);
I suggest:
assert IllegalDataState.apply(Rules.ruleA, condition);

Reason 2: When checking invariants, it becomes counter intuitive to mention an exception. Static methods on exceptions is not a common pattern. The name of the class becomes more informative.

If a exception is to be thrown, the it would be like:
throw new IllegalControlState.Exception(bla bla bla);