DEFENSIVE PROGRAMMING WITH KLOJANG CHECK
Chaining Checks
As mentioned before, Klojang Check lets you chain multiple checks on a single value. The is() and isNot() methods together constitute a fluent API.
You can also chain checks on different values, namely using the and() method. This can make for very concise argument validation:
public void processMessage(List<String> messages, int index) {
Check.notNull(messages).and(from).is(gte(), 0).is(lte(), messages.size());
// process the message ...
}
Note that with the and() method you are in fact breaking out of the fluent API as it returns a new IntCheck or ObjectCheck instance. The code above hopped from an ObjectCheck (for the messages argument) to an IntCheck (for the from argument).