[Guava] Preconditions

Preconditions should be ideal for situations, where there is no specific business exceptions for checking arguments and performance is not an issue.

JavaDoc:

https://google.github.io/guava/releases/19.0/api/docs/com/google/common/base/Preconditions.html

Example:

   /**
    * Returns the positive square root of the given value.
    *
    * @throws IllegalArgumentException if the value is negative
    */
   public static double sqrt(double value) {
     Preconditions.checkArgument(value >= 0.0, "negative value: %s", value);
     // calculate the square root
   }

 

Here is more about checking conditions:

https://github.com/google/guava/wiki/ConditionalFailuresExplained