org.springframework.core.convert.converter

Interface Converter<S,T>

  • Type Parameters:
    S - the source type
    T - the target type
    All Known Implementing Classes:
    DeserializingConverter, SerializingConverter
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.


    @FunctionalInterface
    public interface Converter<S,T>
    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.

    Since:
    3.0
    Author:
    Keith Donald
    • Method Detail

      • convert

        @Nullable
        T convert(S source)
        Convert the source object of type S to target type T.
        Parameters:
        source - the source object to convert, which must be an instance of S (never null)
        Returns:
        the converted object, which must be an instance of T (potentially null)
        Throws:
        java.lang.IllegalArgumentException - if the source cannot be converted to the desired target type