Class ValidationException

  • All Implemented Interfaces:
    Serializable

    public final class ValidationException
    extends RuntimeException
    This exception is thrown when message build fails due to an incorrectly configured message. This will be due to either required fields not being set or two or more fields set to incompatible values. That is setting one field to a given value restricts the values allowed for one or more other fields. This method is "fail slow" meaning that it should contain all the ConfigException.ValidationProblems found with the configured message and not the first problem.

    This exception should not be thrown if a single field is set to an invalid value. Instead an exception is thrown by the setter method when given that invalid value.

    Author:
    Charles W. Rapp
    See Also:
    Serialized Form
    • Constructor Detail

      • ValidationException

        public ValidationException​(Class<?> tc,
                                   List<MultiKey2<String,​String>> problems)
        Creates a new instance of ValidationException for the given class and validation problems.
        Parameters:
        tc - validation exception applies to building this class.
        problems - discovered message class problems.
      • ValidationException

        public ValidationException​(Class<?> tc,
                                   List<MultiKey2<String,​String>> problems,
                                   Throwable cause)
        Creates a new instance of ValidationException for the given class and validation problems.
        Parameters:
        tc - validation exception applies to building this class.
        problems - discovered message class problems.
        cause - underlying cause for this validation exception.
    • Method Detail

      • toString

        public String toString()
        Returns text displaying the message validation problems.
        Overrides:
        toString in class Throwable
        Returns:
        exception in text format.
      • targetClass

        public Class<?> targetClass()
        Returns builder's target class experiencing the validation problems.
        Returns:
        builder target class.
      • problems

        public List<MultiKey2<String,​String>> problems()
        Returns the validation problems as a read-only list.
        Returns:
        problems list.