Interface Converter<S,T>

Type Parameters:
S - The source type
T - The target type
All Superinterfaces:
Comparable<Prioritized>, Prioritized
All Known Subinterfaces:
StringConverter<T>
All Known Implementing Classes:
StringToBooleanConverter, StringToByteConverter, StringToCharacterConverter, StringToCharArrayConverter, StringToDoubleConverter, StringToDurationConverter, StringToFloatConverter, StringToIntegerConverter, StringToLongConverter, StringToOptionalConverter, StringToShortConverter, StringToStringConverter
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@SPI(scope=FRAMEWORK) @FunctionalInterface public interface Converter<S,T> extends Prioritized
A class to convert the source-typed value to the target-typed value
Since:
2.7.6
  • Method Details

    • accept

      default boolean accept(Class<?> sourceType, Class<?> targetType)
      Accept the source type and target type or not
      Parameters:
      sourceType - the source type
      targetType - the target type
      Returns:
      if accepted, return true, or false
    • convert

      T convert(S source)
      Convert the source-typed value to the target-typed value
      Parameters:
      source - the source-typed value
      Returns:
      the target-typed value
    • getSourceType

      default Class<S> getSourceType()
      Get the source type
      Returns:
      non-null
    • getTargetType

      default Class<T> getTargetType()
      Get the target type
      Returns:
      non-null