接口 Converter<S,T>

类型参数:
S - the source type
T - the target type
所有已知实现类:
DeserializingConverter, SerializingConverter
函数接口:
这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

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

作者:
TODAY 2018-07-07 21:33:52
  • 方法概要

    修饰符和类型
    方法
    说明
    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.
    convert(S source)
    Convert the source object of type S to target type T.
  • 方法详细资料

    • convert

      @Nullable T convert(S source)
      Convert the source object of type S to target type T.
      参数:
      source - the source object to convert, which must be an instance of S (never null)
      返回:
      the converted object, which must be an instance of T (potentially null)
      抛出:
      IllegalArgumentException - if the source cannot be converted to the desired target type
    • andThen

      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.
      类型参数:
      U - the type of output of both the after Converter and the composed Converter
      参数:
      after - the Converter to apply after this Converter is applied
      返回:
      a composed Converter that first applies this Converter and then applies the after Converter
      从以下版本开始:
      4.0