Interface ConfigConverter<T>

Type Parameters:
T - the Java value type
All Known Implementing Classes:
GenericConverters, LegacyParserAdapter, ScalarConverter

public interface ConfigConverter<T>
Converts one Java value type to and from the configuration plain-data model. Implementations must return plain data from toPlain(Object, ConversionContext). For every value x of the declared type whose collections and arrays contain no null element, fromPlain(toPlain(x)) equals x. Typed collection and reference-array null elements are omitted on write with one located warning per field; read behavior is unchanged. Null map values and null whole fields remain plain data and round-trip. For every canonical plain value p emitted by the converter (p = toPlain(x)), toPlain(fromPlain(p)) equals p. A converter may also accept noncanonical input q; its canonical form is toPlain(fromPlain(q)), and normalization must be stable: fromPlain(toPlain(fromPlain(q))) equals fromPlain(q). Equality is semantic value equality, not object identity; numeric plain values compare by value. Accepted coercions, such as numeric text to a number or duplicate list elements to a set, do not require preserving the noncanonical input representation. The framework relies on forward equality for reload merges and leaf edits, including preservation of untouched in-memory siblings.
Since:
6.3.0
  • Method Details

    • toPlain

      Object toPlain(T value, ConversionContext ctx) throws ConversionException
      Converts a Java value to plain data.
      Parameters:
      value - the Java value
      ctx - the immutable conversion location and recursive dispatcher
      Returns:
      plain data
      Throws:
      ConversionException - when conversion cannot preserve the value
    • fromPlain

      T fromPlain(Object plain, ConversionContext ctx) throws ConversionException
      Converts plain data to a Java value.
      Parameters:
      plain - the value read from the document
      ctx - the immutable conversion location and recursive dispatcher
      Returns:
      the Java value
      Throws:
      ConversionException - when the input cannot be converted