Class ModelException

All Implemented Interfaces:
Serializable

public class ModelException extends RuntimeException
Thrown if the classes in the entity model are for some reason invalid.
Author:
Tobias Liefke
See Also:
  • Field Details

  • Constructor Details

    • ModelException

      public ModelException(String message)
      Creates a new instance of ModelException.
      Parameters:
      message - the message of the exception
    • ModelException

      public ModelException(String message, Throwable cause)
      Creates a new instance of ModelException.
      Parameters:
      message - the detail message of the exception
      cause - the origin of this exception
  • Method Details

    • buildErrorMessage

      public static String buildErrorMessage(String errorMessage, Object... parameters)
      Builds the error message from the given message and parameters.
      Parameters:
      errorMessage - the message, each of {} is replaced by one of the given parameters
      parameters - the optional parameters for the error message
      Returns:
      the error message
    • mustExist

      public static void mustExist(Object value, String errorMessage, Object... parameters)
      Throws a ModelException if the given value is null.
      Parameters:
      value - the value that should not be null
      errorMessage - the message to include in the exception, if the value is null, each of {} is replaced by one of the given parameters
      parameters - the optional parameters for the error message
      Throws:
      ModelException - if the value is null
    • test

      public static void test(boolean condition, String errorMessage, Object... parameters)
      Throws a ModelException if the given condition is not met.
      Parameters:
      condition - the condition to check
      errorMessage - the message to include in the exception, if the condition is not true, each of {} is replaced by one of the given parameters
      parameters - the optional parameters for the error message
      Throws:
      ModelException - if the condition is false