org.springframework.validation

Class ObjectError

    • Constructor Detail

      • ObjectError

        public ObjectError(java.lang.String objectName,
                           java.lang.String defaultMessage)
        Create a new instance of the ObjectError class.
        Parameters:
        objectName - the name of the affected object
        defaultMessage - the default message to be used to resolve this message
      • ObjectError

        public ObjectError(java.lang.String objectName,
                           @Nullable
                           java.lang.String[] codes,
                           @Nullable
                           java.lang.Object[] arguments,
                           @Nullable
                           java.lang.String defaultMessage)
        Create a new instance of the ObjectError class.
        Parameters:
        objectName - the name of the affected object
        codes - the codes to be used to resolve this message
        arguments - the array of arguments to be used to resolve this message
        defaultMessage - the default message to be used to resolve this message
    • Method Detail

      • getObjectName

        public java.lang.String getObjectName()
        Return the name of the affected object.
      • wrap

        public void wrap(java.lang.Object source)
        Preserve the source behind this error: possibly an Exception (typically PropertyAccessException) or a Bean Validation ConstraintViolation.

        Note that any such source object is being stored as transient: that is, it won't be part of a serialized error representation.

        Parameters:
        source - the source object
        Since:
        5.0.4
      • unwrap

        public <T> T unwrap(java.lang.Class<T> sourceType)
        Unwrap the source behind this error: possibly an Exception (typically PropertyAccessException) or a Bean Validation ConstraintViolation.

        The cause of the outermost exception will be introspected as well, e.g. the underlying conversion exception or exception thrown from a setter (instead of having to unwrap the PropertyAccessException in turn).

        Returns:
        the source object of the given type
        Throws:
        java.lang.IllegalArgumentException - if no such source object is available (i.e. none specified or not available anymore after deserialization)
        Since:
        5.0.4
      • contains

        public boolean contains(java.lang.Class<?> sourceType)
        Check the source behind this error: possibly an Exception (typically PropertyAccessException) or a Bean Validation ConstraintViolation.

        The cause of the outermost exception will be introspected as well, e.g. the underlying conversion exception or exception thrown from a setter (instead of having to unwrap the PropertyAccessException in turn).

        Returns:
        whether this error has been caused by a source object of the given type
        Since:
        5.0.4