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
FieldsModifier and TypeFieldDescriptionstatic final StringError code that a type mismatch error will be registered with. -
Constructor Summary
ConstructorsConstructorDescriptionTypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType) Create a newTypeMismatchException.TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause) Create a newTypeMismatchException.TypeMismatchException(Object value, Class<?> requiredType) Create a newTypeMismatchExceptionwithout aPropertyChangeEvent.TypeMismatchException(Object value, Class<?> requiredType, Throwable cause) Create a newTypeMismatchExceptionwithout 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).voidinitPropertyName(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
getPropertyChangeEventMethods inherited from class org.springframework.core.NestedRuntimeException
contains, getMessage, getMostSpecificCause, getRootCauseMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, 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 (ornullif not known)cause- the root cause (may benull)
-
TypeMismatchException
Create a newTypeMismatchExceptionwithout aPropertyChangeEvent.- Parameters:
value- the offending value that couldn't be converted (may benull)requiredType- the required target type (ornullif not known)- See Also:
-
TypeMismatchException
public TypeMismatchException(@Nullable Object value, @Nullable Class<?> requiredType, @Nullable Throwable cause) Create a newTypeMismatchExceptionwithout aPropertyChangeEvent.- Parameters:
value- the offending value that couldn't be converted (may benull)requiredType- the required target type (ornullif 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:
getPropertyNamein classPropertyAccessException
-
getValue
Return the offending value (may benull).- Overrides:
getValuein classPropertyAccessException
-
getRequiredType
Return the required target type, if any. -
getErrorCode
Description copied from class:PropertyAccessExceptionReturn a corresponding error code for this type of exception.- Specified by:
getErrorCodein classPropertyAccessException
-