类 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 anObjectError
.- 从以下版本开始:
- 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 anException
(typicallyPropertyAccessException
) or a Bean ValidationConstraintViolation
.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 anException
(typicallyPropertyAccessException
) or a Bean ValidationConstraintViolation
.void
wrap(Object source)
Preserve the source behind this error: possibly anException
(typicallyPropertyAccessException
) or a Bean ValidationConstraintViolation
.从类继承的方法 org.springframework.context.support.DefaultMessageSourceResolvable
getArguments, getCode, getCodes, getDefaultMessage, resolvableToString, shouldRenderDefaultMessage
构造器详细资料
ObjectError
public ObjectError(String objectName, String defaultMessage)
Create a new instance of the ObjectError class.- 参数:
objectName
- the name of the affected objectdefaultMessage
- 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 objectcodes
- the codes to be used to resolve this messagearguments
- the array of arguments to be used to resolve this messagedefaultMessage
- 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 anException
(typicallyPropertyAccessException
) or a Bean ValidationConstraintViolation
.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 anException
(typicallyPropertyAccessException
) or a Bean ValidationConstraintViolation
.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 anException
(typicallyPropertyAccessException
) or a Bean ValidationConstraintViolation
.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
hashCode
public int hashCode()
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()
.