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, Josh Cummings
  • Method summary

    Modifier and Type
    Method
    Description
    default <U>&nbsp;Converter<s,U>
    andThen(Converter<? super T, ? extends U>&nbsp;after)
    Construct a composed Converter that first applies this Converter to its input, and then applies the after Converter to the result.
    convert(s&nbsp;source)
    Convert the source object of type s to target type T.
  • Method Details

    • convert

      @Nullable T&nbsp;convert(s&nbsp;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:
      IllegalArgumentException - if the source cannot be converted to the desired target type
    • andThen

      default&nbsp;<U>&nbsp;Converter<s,U>&nbsp;andThen(Converter<? super T, ? extends U>&nbsp;after)
      Construct a composed Converter that first applies this Converter to its input, and then applies the after Converter to the result.
      Type Parameters:
      U - the type of output of both the after Converter and the composed Converter
      Parameters:
      after - the Converter to apply after this Converter is applied
      Returns:
      a composed Converter that first applies this Converter and then applies the after Converter
      since:
      5.3