Top Description Methods
org.springframework.core.convert.converter

public Interface Converter<S, T>

Known Direct Implementers
org.springframework.core.convert.converter.ConvertingComparator.ConversionServiceConverter, org.springframework.core.convert.support.CharacterToNumberFactory.CharacterToNumber, org.springframework.core.convert.support.ObjectToStringConverter, org.springframework.core.convert.support.PropertiesToStringConverter, org.springframework.core.convert.support.StringToBooleanConverter, org.springframework.core.convert.support.StringToCharacterConverter, org.springframework.core.convert.support.StringToCharsetConverter, org.springframework.core.convert.support.StringToCurrencyConverter, org.springframework.core.convert.support.StringToEnumConverterFactory.StringToEnum, org.springframework.core.convert.support.StringToLocaleConverter, org.springframework.core.convert.support.StringToNumberConverterFactory.StringToNumber, org.springframework.core.convert.support.StringToPatternConverter, org.springframework.core.convert.support.StringToPropertiesConverter, org.springframework.core.convert.support.StringToRegexConverter, org.springframework.core.convert.support.StringToTimeZoneConverter, org.springframework.core.convert.support.StringToUUIDConverter, org.springframework.core.convert.support.ZonedDateTimeToCalendarConverter, org.springframework.core.convert.support.ZoneIdToTimeZoneConverter, org.springframework.core.convert.support.EnumToIntegerConverter, org.springframework.core.convert.support.EnumToStringConverter, org.springframework.core.convert.support.IntegerToEnumConverterFactory.IntegerToEnum, org.springframework.core.convert.support.NumberToCharacterConverter, org.springframework.core.convert.support.NumberToNumberConverterFactory.NumberToNumber, org.springframework.core.serializer.support.DeserializingConverter, org.springframework.core.serializer.support.SerializingConverter
Annotations
@FunctionalInterface
Type Parameters
<S>
the source type
<T>
the target type
Imports
org.springframework.lang.Nullable, org.springframework.util.Assert

A converter converts a source object of type S to a target of type T.

Implementations of this interface are thread-safe and can be shared.

Implementations may additionally implement ConditionalConverter.

Authors
Keith Donald, Josh Cummings
Since
3.0

Method Summary

Modifier and TypeMethod and Description
public default <
the type of output of both the after Converter and the composed Converter
U
>
Converter<S, U>

Returns:

a composed Converter that first applies this Converter and then applies the after Converter
andThen
(Converter<? super T, ? extends U>
the Converter to apply after this Converter is applied
after
)

Construct a composed Converter that first applies this Converter to its input, and then applies the after Converter to the result.

public T

Returns:

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

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

Method Detail

andThenback to summary
public default <U> Converter<S, U> andThen(Converter<? super T, ? extends U> after)

Construct a composed Converter that first applies this Converter to its input, and then applies the after Converter to the result.

Parameters
<U>
the type of output of both the after Converter and the composed Converter
after:Converter<? super T, ? extends U>

the Converter to apply after this Converter is applied

Returns:Converter<S, U>

a composed Converter that first applies this Converter and then applies the after Converter

Since
5.3
convertback to summary
public T convert(S source)

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

Parameters
source:S

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
@Nullable
Exceptions
IllegalArgumentException:
if the source cannot be converted to the desired target type