Class AbstractStringParsingConverter<T>

java.lang.Object
org.litebridgedb.convert.converter.AbstractStringParsingConverter<T>
Type Parameters:
T - the target type
All Implemented Interfaces:
Converter<T>, ConverterFunction<T>
Direct Known Subclasses:
BooleanConverter, CharacterConverter, SqlDateConverter

public abstract class AbstractStringParsingConverter<T> extends Object implements Converter<T>
An abstract base class for Converter implementations that primarily convert values by parsing their string representation.

This class handles null values, identity conversions (where the input is already an instance of the target type), and delegates the parsing of non-blank strings to convertString(String).

  • Constructor Details

    • AbstractStringParsingConverter

      public AbstractStringParsingConverter()
  • Method Details

    • convert

      public @Nullable T convert(@Nullable Object value)
      Converts the given value to the target type.

      The conversion process follows these steps:

      1. If the value is null, returns null.
      2. If the value is already an instance of the target type, returns it as-is.
      3. Otherwise, converts the value to a string and, if not blank, calls convertString(String).
      Specified by:
      convert in interface ConverterFunction<T>
      Parameters:
      value - the value to convert, may be null
      Returns:
      the converted value, or null
    • convertString

      protected abstract T convertString(String value)
      Parses a string value into the target type.
      Parameters:
      value - the string value to parse
      Returns:
      the parsed value