List of usage examples for org.springframework.core.convert TypeDescriptor isPrimitive
public boolean isPrimitive()
From source file:org.springframework.core.convert.support.GenericConversionService.java
/** * Template method to convert a null source. * <p>Default implementation returns <code>null</code>. * Throws a {@link ConversionFailedException} if the targetType is a primitive type, * as <code>null</code> cannot be assigned to a primitive type. * Subclasses may override to return custom null objects for specific target types. * @param sourceType the sourceType to convert from * @param targetType the targetType to convert to * @return the converted null object// w w w . j a v a 2 s .co m */ protected Object convertNullSource(TypeDescriptor sourceType, TypeDescriptor targetType) { if (targetType.isPrimitive()) { throw new ConversionFailedException(sourceType, targetType, null, new IllegalArgumentException("A null value cannot be assigned to a primitive type")); } return null; }