package se.raddo.raddose3D;

/**
 * Class that contains a number of argument validation functions. Objects can be
 * tested against null, objects can be tested whether they are instances of
 * other classes, etc.
 * If the validation fails the function will throw an IllegalArgumentException
 * with a (hopefully) helpful error message.
 */
public class Assertions {

  /**
   * Prefix used for any raised RuntimeExceptions.
   */
  private final String sourceMessage;

  /**
   * Default constructor with no custom exception prefix.
   */
  public Assertions() {
    sourceMessage = "";
  }

  /**
   * Constructor with a custom exception prefix.
   * 
   * @param exceptionPrefix
   *          A String that will be prefixed to any exceptions. May contain a
   *          helpful message to the user indicating where something went wrong.
   */
  public Assertions(final String exceptionPrefix) {
    sourceMessage = exceptionPrefix;
  }

  /**
   * Throw a runtime exception if a variable is set to null.
   * 
   * @param variable
   *          The variable to test.
   * @param errorMessage
   *          A helpful message that will be included in the runtime exception.
   */
  public void checkIsNotNull(final Object variable,
      final String errorMessage) throws IllegalArgumentException {
    if (variable == null) {
      throw new IllegalArgumentException(sourceMessage.concat(errorMessage));
    }
  }

  /**
   * Throw a runtime exception if a variable is not of a given type, or is set
   * to null.
   * 
   * @param variable
   *          The variable to test.
   * @param classToTest
   *          class that variable should be an instance of. (e.g: Double.class)
   * @param errorMessage
   *          A helpful message that will be included in the runtime exception.
   */
  public void checkIsClass(final Object variable, final Class<?> classToTest,
      final String errorMessage) {
    if ((variable == null)
        || (classToTest == null)
        || (!classToTest.isAssignableFrom(variable.getClass()))) {
      throw new IllegalArgumentException(sourceMessage.concat(errorMessage));
    }
  }
}

@@ -1161,32 +1161,113 @@
 time exception.%0A
+   * @throws IllegalArgumentException%0A   *           Thrown if variable is null.%0A
    */%0A  public v
@@ -1859,24 +1859,140 @@
  exception.%0A
+   * @throws IllegalArgumentException%0A   *           Thrown if variable is not of the correct class or set to null.%0A
    */%0A  publ
@@ -2095,16 +2095,48 @@
 Message)
+ throws IllegalArgumentException
  %7B%0A    i

Improve documentation