(Quick Reference)

Purpose

Overview of methods provided to more easily extend SanityChecker.

checkYourselfBeforeYouWreckYourself

A method which should be used within each sanity check to ensure the check method has been invoked prior to the first sanity check.

Throws IllegalStateException.

pass

Indicate that the current entity has passed a sanity check.

fail

Indicate that the current entity has failed a sanity check.

Example

public boolean mySanityCheck() {
    mySanityCheck(allowPassOnNull)
}

public boolean mySanityCheck(boolean allowPassOnNull) throws IllegalStateException { checkYourselfBeforeYouWreckYourself()

if (allowPassOnNull && entity == null) { pass("mySanityCheck", "My sanity check condition." return true }

// Implicit isNotNull. isNotNull()

if (checkForFailure(myCondition)) { fail("mySanityCheck", "My sanity check condition." return false }

pass("mySanityCheck", "My sanity check condition." return true }

Description

The above methods will throw an IllegalStateException if check has not been invoked prior to calling this sanity check.

The stub method above ensures that the sanity checker's allowPassOnNull behavior is taken into account.

The method short-circuits a pass if the entity is null and allowPassOnNull is true.

If allowPassOnNull is false, then the method implicitly checks if the entity isNotNull.

Whether or not it passes this check, it will go on to perform the actual check.