Class ConverterFactories

java.lang.Object
org.pkl.config.java.mapper.ConverterFactories

public final class ConverterFactories extends Object
Predefined conversions for composite types (objects, collections, etc.).
  • Field Details

    • pNullToAny

      public static final ConverterFactory pNullToAny
      Conversion from pkl.base#Null to any non-primitive type. The conversion result is always null.
    • pObjectToPObject

      public static final ConverterFactory pObjectToPObject
      Identity conversion for PObject.
    • pStringToEnum

      public static final ConverterFactory pStringToEnum
      Conversion from pkl.base#String to Java Enum type. If there is no exact match between string and enum value, some variations are tried. For example, both "house-of-cards" and "house of cards" will be successfully matched to enum value HOUSE_OF_CARDS.
    • pAnyToOptional

      public static final ConverterFactory pAnyToOptional
      Conversion from any Pkl value to Optional. Returns an empty optional for pkl.base#Null and a present optional otherwise.
    • pCollectionToArray

      public static final ConverterFactory pCollectionToArray
      Conversion from pkl.base#Collection to Java primitive or object array.
    • pCollectionToCollection

      public static final ConverterFactory pCollectionToCollection
      Conversion from pkl.base#Collection to Collection. The concrete implementation type is determined using TypeMappings.
    • pMapToMap

      public static final ConverterFactory pMapToMap
      Conversion from pkl.base#Map to Map. The concrete implementation type is determined using TypeMappings.
    • pObjectToDataObject

      public static final ConverterFactory pObjectToDataObject
      Conversion from Pkl module or object to Java data object. The conversion is performed as follows:

      1. Find the Java class constructor with the highest number of parameters.
      2. Correlate constructor parameters with Pkl object properties by name.
      3. Convert each Pkl property value to the corresponding constructor parameter's type.
      4. Invoke the constructor.

      Dynamic and class based Pkl objects are equally supported. The Pkl object must contain all properties defined by the Java class constructor. Any additional Pkl object properties are ignored.

      Unless the Java 8+ compiler option -parameters is set, constructor parameters must be annotated with Named or javax.inject.Named.

    • pObjectToMap

      public static final ConverterFactory pObjectToMap
    • pPairToPair

      public static final ConverterFactory pPairToPair
      Conversion from pkl.base#Pair to Pair.
    • all

      public static final Collection<ConverterFactory> all
      All conversions defined in this class.