Package org.springframework.beans
Class TypeMismatchException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.beans.BeansException
org.springframework.beans.PropertyAccessException
org.springframework.beans.TypeMismatchException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ConversionNotSupportedException
,MethodArgumentTypeMismatchException
Exception thrown on a type mismatch when trying to set a bean property.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Error code that a type mismatch error will be registered with. -
Constructor Summary
ConstructorDescriptionTypeMismatchException
(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType) Create a newTypeMismatchException
.TypeMismatchException
(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause) Create a newTypeMismatchException
.TypeMismatchException
(Object value, Class<?> requiredType) Create a newTypeMismatchException
without aPropertyChangeEvent
.TypeMismatchException
(Object value, Class<?> requiredType, Throwable cause) Create a newTypeMismatchException
without aPropertyChangeEvent
. -
Method Summary
Modifier and TypeMethodDescriptionReturn a corresponding error code for this type of exception.Return the name of the affected property, if available.Class<?>
Return the required target type, if any.getValue()
Return the offending value (may benull
).void
initPropertyName
(String propertyName) Initialize this exception's property name for exposure throughgetPropertyName()
, as an alternative to having it initialized via aPropertyChangeEvent
.Methods inherited from class org.springframework.beans.PropertyAccessException
getPropertyChangeEvent
Methods inherited from class org.springframework.core.NestedRuntimeException
contains, getMostSpecificCause, getRootCause
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
ERROR_CODE
Error code that a type mismatch error will be registered with.- See Also:
-
-
Constructor Details
-
TypeMismatchException
Create a newTypeMismatchException
.- Parameters:
propertyChangeEvent
- the PropertyChangeEvent that resulted in the problemrequiredType
- the required target type
-
TypeMismatchException
public TypeMismatchException(PropertyChangeEvent propertyChangeEvent, @Nullable Class<?> requiredType, @Nullable Throwable cause) Create a newTypeMismatchException
.- Parameters:
propertyChangeEvent
- the PropertyChangeEvent that resulted in the problemrequiredType
- the required target type (ornull
if not known)cause
- the root cause (may benull
)
-
TypeMismatchException
Create a newTypeMismatchException
without aPropertyChangeEvent
.- Parameters:
value
- the offending value that couldn't be converted (may benull
)requiredType
- the required target type (ornull
if not known)- See Also:
-
TypeMismatchException
public TypeMismatchException(@Nullable Object value, @Nullable Class<?> requiredType, @Nullable Throwable cause) Create a newTypeMismatchException
without aPropertyChangeEvent
.- Parameters:
value
- the offending value that couldn't be converted (may benull
)requiredType
- the required target type (ornull
if not known)cause
- the root cause (may benull
)- See Also:
-
-
Method Details
-
initPropertyName
Initialize this exception's property name for exposure throughgetPropertyName()
, as an alternative to having it initialized via aPropertyChangeEvent
.- Parameters:
propertyName
- the property name to expose- Since:
- 5.0.4
- See Also:
-
getPropertyName
Return the name of the affected property, if available.- Overrides:
getPropertyName
in classPropertyAccessException
-
getValue
Return the offending value (may benull
).- Overrides:
getValue
in classPropertyAccessException
-
getRequiredType
Return the required target type, if any. -
getErrorCode
Description copied from class:PropertyAccessException
Return a corresponding error code for this type of exception.- Specified by:
getErrorCode
in classPropertyAccessException
-