org.springframework.validation

## 类 ObjectError

- java.lang.Object
- - org.springframework.context.support.DefaultMessageSourceResolvable
  - - org.springframework.validation.ObjectError

- 所有已实现的接口:
    Serializable, MessageSourceResolvable
  直接已知子类:
    FieldError

      public class ObjectError
      extends DefaultMessageSourceResolvable

  Encapsulates an object error, that is, a global reason for rejecting an object.

  See the `DefaultMessageCodesResolver` javadoc for details on how a message code list is built for an `ObjectError`.

  从以下版本开始:
    10.03.2003
  作者:
    Juergen Hoeller
  另请参阅:
    `FieldError`, `DefaultMessageCodesResolver`, 序列化表格

- - ### 构造器概要

    构造器
    构造器和说明
    `ObjectError(String objectName, String defaultMessage)` Create a new instance of the ObjectError class.
    `ObjectError(String objectName, String[] codes, Object[] arguments, String defaultMessage)` Create a new instance of the ObjectError class.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `boolean` | `contains(Class<?> sourceType)` Check the source behind this error: possibly an `Exception` (typically `PropertyAccessException`) or a Bean Validation `ConstraintViolation`.
    `boolean` | `equals(Object other)`
    `String` | `getObjectName()` Return the name of the affected object.
    `int` | `hashCode()`
    `String` | `toString()` The default implementation exposes the attributes of this MessageSourceResolvable.
    `<T> T` | `unwrap(Class<T> sourceType)` Unwrap the source behind this error: possibly an `Exception` (typically `PropertyAccessException`) or a Bean Validation `ConstraintViolation`.
    `void` | `wrap(Object source)` Preserve the source behind this error: possibly an `Exception` (typically `PropertyAccessException`) or a Bean Validation `ConstraintViolation`.

    - ### 从类继承的方法 org.springframework.context.support.DefaultMessageSourceResolvable

      `getArguments, getCode, getCodes, getDefaultMessage, resolvableToString`

    - ### 从类继承的方法 java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 构造器详细资料

    - #### ObjectError

          public ObjectError(String objectName,
                             String defaultMessage)

      Create a new instance of the ObjectError class.
      参数:
        `objectName` - the name of the affected object
        `defaultMessage` - the default message to be used to resolve this message

    - #### ObjectError

          public ObjectError(String objectName,
                             @Nullable
                             String[] codes,
                             @Nullable
                             Object[] arguments,
                             @Nullable
                             String defaultMessage)

      Create a new instance of the ObjectError class.
      参数:
        `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

  - ### 方法详细资料

    - #### getObjectName

          public String getObjectName()

      Return the name of the affected object.

    - #### wrap

          public void wrap(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.

      参数:
        `source` - the source object
      从以下版本开始:
        5.0.4

    - #### unwrap

          public <T> T unwrap(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).

      返回:
        the source object of the given type
      抛出:
        `IllegalArgumentException` - if no such source object is available (i.e. none specified or not available anymore after deserialization)
      从以下版本开始:
        5.0.4

    - #### contains

          public boolean contains(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).

      返回:
        whether this error has been caused by a source object of the given type
      从以下版本开始:
        5.0.4

    - #### equals

          public boolean equals(@Nullable
                                Object other)

      覆盖:
        `equals` 在类中 `DefaultMessageSourceResolvable`

    - #### hashCode

          public int hashCode()

      覆盖:
        `hashCode` 在类中 `DefaultMessageSourceResolvable`

    - #### toString

          public String toString()

      从类复制的说明: `DefaultMessageSourceResolvable`
      The default implementation exposes the attributes of this MessageSourceResolvable.

      To be overridden in more specific subclasses, potentially including the resolvable content through `resolvableToString()`.

      覆盖:
        `toString` 在类中 `DefaultMessageSourceResolvable`
      另请参阅:
        `DefaultMessageSourceResolvable.resolvableToString()`