类 ObjectError

所有已实现的接口:
MessageSourceResolvable, Serializable
直接已知子类:
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.

从以下版本开始:
4.0
作者:
Juergen Hoeller
另请参阅:
  • 构造器详细资料

    • 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
    • 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)
    • 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
    • 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
      另请参阅: