Top Description Inners Constructors Methods
org.springframework.core.convert.support

pack-priv final Class NumberToNumberConverterFactory

extends Object
implements ConverterFactory<Number, Number>, ConditionalConverter
Class Inheritance
All Implemented Interfaces
org.springframework.core.convert.converter.ConditionalConverter, org.springframework.core.convert.converter.ConverterFactory
Imports
org.springframework.core.convert.TypeDescriptor, org.springframework.core.convert.converter.ConditionalConverter, .Converter, .ConverterFactory, org.springframework.util.NumberUtils

Converts from any JDK-standard Number implementation to any other JDK-standard Number implementation.

Support Number classes including Byte, Short, Integer, Float, Double, Long, BigInteger, BigDecimal. This class delegates to NumberUtils#convertNumberToTargetClass(Number, Class) to perform the conversion.

Author
Keith Donald
Since
3.0
See Also
java.lang.Byte, java.lang.Short, java.lang.Integer, java.lang.Long, java.math.BigInteger, java.lang.Float, java.lang.Double, java.math.BigDecimal, NumberUtils

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public <T extends Number> Converter<Number, T>
getConverter(Class<T>
the target type to convert to
targetType
)

Implements org.springframework.core.convert.converter.ConverterFactory.getConverter.

Get the converter to convert from S to target type T, where T is also an instance of R.

public boolean
matches(TypeDescriptor
the type descriptor of the field we are converting from
sourceType
,
TypeDescriptor
the type descriptor of the field we are converting to
targetType
)

Implements org.springframework.core.convert.converter.ConditionalConverter.matches.

Should the conversion from sourceType to targetType currently under consideration be selected?

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NumberToNumberConverterFactoryback to summary
pack-priv NumberToNumberConverterFactory()

Method Detail

getConverterback to summary
public <T extends Number> Converter<Number, T> getConverter(Class<T> targetType)

Implements org.springframework.core.convert.converter.ConverterFactory.getConverter.

Doc from org.springframework.core.convert.converter.ConverterFactory.getConverter.

Get the converter to convert from S to target type T, where T is also an instance of R.

Parameters
<T>
the target type
targetType:Class<T>

the target type to convert to

Returns:Converter<Number, T>

a converter from S to T

Annotations
@Override
matchesback to summary
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)

Implements org.springframework.core.convert.converter.ConditionalConverter.matches.

Doc from org.springframework.core.convert.converter.ConditionalConverter.matches.

Should the conversion from sourceType to targetType currently under consideration be selected?

Parameters
sourceType:TypeDescriptor

the type descriptor of the field we are converting from

targetType:TypeDescriptor

the type descriptor of the field we are converting to

Returns:boolean

true if conversion should be performed, false otherwise

Annotations
@Override
org.springframework.core.convert.support back to summary

private final Class NumberToNumberConverterFactory.NumberToNumber<T extends Number>

extends Object
implements Converter<Number, T extends Number>
Class Inheritance
  • java.lang.Object
  • org.springframework.core.convert.support.NumberToNumberConverterFactory.NumberToNumber
All Implemented Interfaces
org.springframework.core.convert.converter.Converter

Field Summary

Modifier and TypeField and Description
private final Class<T>

Constructor Summary

AccessConstructor and Description
pack-priv
NumberToNumber(Class<T> targetType)

Method Summary

Modifier and TypeMethod and Description
public T
convert(Number
the source object to convert, which must be an instance of S (never null)
source
)

Implements org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

targetTypeback to summary
private final Class<T> targetType

Constructor Detail

NumberToNumberback to summary
pack-priv NumberToNumber(Class<T> targetType)

Method Detail

convertback to summary
public T convert(Number source)

Implements org.springframework.core.convert.converter.Converter.convert.

Doc from org.springframework.core.convert.converter.Converter.convert.

Convert the source object of type S to target type T.

Parameters
source:Number

the source object to convert, which must be an instance of S (never null)

Returns:T

the converted object, which must be an instance of T (potentially null)

Annotations
@Override