Class UnexpectedSwitchCaseException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.ehrbase.api.exception.UnexpectedSwitchCaseException
All Implemented Interfaces:
Serializable

public class UnexpectedSwitchCaseException extends RuntimeException

This exception is thrown when a case has occurred in a switch block that cannot be handled correctly.

Typical uses in a switch statement:

  1. unexpected default case
  2. explicitly not sensibly treatable case
  3. unexpected default case with fall-through of not sensibly treatable case (combination of 1. and 2.)
See Also:
  • Constructor Details

    • UnexpectedSwitchCaseException

      public UnexpectedSwitchCaseException(Enum<?> enumValue)
      Creates a message from the enumValue parameter.
      The message is based on enumValue.name(), so that the format is stable, e.g. in case of i18n.
      Parameters:
      enumValue - must not be null
    • UnexpectedSwitchCaseException

      public UnexpectedSwitchCaseException(Enum<?> enumValue, String additionalMessage)
      Creates a message from the enumValue parameter.
      The message is based on enumValue.name(), so that the format is stable, e.g. in case of i18n.
      Parameters:
      enumValue - must not be null
      additionalMessage - additional text for generated message
    • UnexpectedSwitchCaseException

      public UnexpectedSwitchCaseException(Integer intValue)
      Creates a message from the intValue parameter
      Parameters:
      intValue -
    • UnexpectedSwitchCaseException

      public UnexpectedSwitchCaseException(Integer intValue, String additionalMessage)
      Creates a message from the intValue parameter
      Parameters:
      intValue -
      additionalMessage - additional text for generated message
    • UnexpectedSwitchCaseException

      public UnexpectedSwitchCaseException(String stringValue)
      Creates a message from the stringValue parameter
      Parameters:
      stringValue -
    • UnexpectedSwitchCaseException

      public UnexpectedSwitchCaseException(String stringValue, String additionalMessage)
      Creates a message from the stringValue parameter
      Parameters:
      stringValue -
      additionalMessage - additional text for generated message
  • Method Details

    • formatMessage

      public static String formatMessage(Enum<?> enumValue, String additionalMessage)
      Creates the message of a UnexpectedSwitchCaseException containing the simple class name of the enumValue parameter. The message is based on enumValue.name(), so that the format is stable, e.g. in case of i18n.
      Parameters:
      enumValue - must not be null
      additionalMessage - additional text for generated message (optional)
      Returns:
    • formatMessage

      public static String formatMessage(Object value, String additionalMessage)
      Creates the message of a UnexpectedSwitchCaseException based on the given parameters.
      Parameters:
      value -
      additionalMessage - additional text for generated message (optional)
      Returns:
    • formatMessage

      public static String formatMessage(String type, Object value, String additionalMessage)
      Creates the message of a UnexpectedSwitchCaseException based on the given parameters.
      Parameters:
      type - e.g. enumValue.getClass().getSimpleName()
      value - unsupported value in switch
      additionalMessage - additional text for generated message (optional)
      Returns: