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

pack-priv final Class StringToNumberConverterFactory

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

Converts from a String any JDK-standard Number implementation.

Support Number classes including Byte, Short, Integer, Float, Double, Long, BigInteger, BigDecimal. This class delegates to NumberUtils#parseNumber(String, 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<String, 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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StringToNumberConverterFactoryback to summary
pack-priv StringToNumberConverterFactory()

Method Detail

getConverterback to summary
public <T extends Number> Converter<String, 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<String, T>

a converter from S to T

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

private final Class StringToNumberConverterFactory.StringToNumber<T extends Number>

extends Object
implements Converter<String, T extends Number>
Class Inheritance
  • java.lang.Object
  • org.springframework.core.convert.support.StringToNumberConverterFactory.StringToNumber
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
public
StringToNumber(Class<T> targetType)

Method Summary

Modifier and TypeMethod and Description
public T
convert(String
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

StringToNumberback to summary
public StringToNumber(Class<T> targetType)

Method Detail

convertback to summary
public T convert(String 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:String

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
@Nullable