Interface Converter<T>

Type Parameters:
T - the target Java type this converter handles
All Superinterfaces:
ConverterFunction<T>
All Known Subinterfaces:
SqlConverter<T>
All Known Implementing Classes:
AbstractNumberConverter, AbstractStringParsingConverter, BigDecimalConverter, BigIntegerConverter, BooleanConverter, ByteArrayConverter, ByteConverter, CharacterConverter, DateConverter, DoubleConverter, FloatConverter, GenericConverter, GenericSqlConverter, IntegerConverter, LocalDateConverter, LocalDateTimeConverter, LongConverter, OffsetDateTimeConverter, ShortConverter, SqlDateConverter, SqlTimeConverter, SqlTimestampConverter, StringConverter, ZonedDateTimeConverter

public interface Converter<T> extends ConverterFunction<T>
Represents a converter for a specific Java type.

A Converter is responsible for translating an arbitrary object to the target type T. It also provides information about the target type it handles.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default converter priority (10).
  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable Class<?>
    Returns the primitive counterpart of the target class, if applicable.
    default int
    Returns the priority of this converter.
    Returns the target Java class this converter handles.

    Methods inherited from interface org.litebridge.convert.converter.ConverterFunction

    convert
  • Field Details

    • DEFAULT_PRIORITY

      static final int DEFAULT_PRIORITY
      Default converter priority (10).
      See Also:
  • Method Details

    • type

      Class<?> type()
      Returns the target Java class this converter handles.
      Returns:
      the target Java class
    • primitiveType

      default @Nullable Class<?> primitiveType()
      Returns the primitive counterpart of the target class, if applicable.
      Returns:
      the primitive type, or null if there is no primitive counterpart
    • priority

      default int priority()
      Returns the priority of this converter.

      Converters with lower priority values converters are preferred if there are data type overlaps.

      As an example, if there are two converters A and B for type String, if A has a priority of 1 and B has a priority of 2, then A will be chosen to perform the conversion.

      Returns:
      the priority of this converter