Package org.pkl.config.java.mapper
Class ConverterFactories
java.lang.Object
org.pkl.config.java.mapper.ConverterFactories
Predefined conversions for composite types (objects, collections, etc.).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Collection<ConverterFactory> All conversions defined in this class.static final ConverterFactoryConversion from any Pkl value toOptional.static final ConverterFactoryConversion frompkl.base#Collectionto Java primitive or object array.static final ConverterFactoryConversion frompkl.base#CollectiontoCollection.static final ConverterFactoryConversion frompkl.base#MaptoMap.static final ConverterFactoryConversion frompkl.base#Nullto any non-primitive type.static final ConverterFactoryConversion from Pkl module or object to Java data object.static final ConverterFactorystatic final ConverterFactoryIdentity conversion forPObject.static final ConverterFactoryConversion frompkl.base#PairtoPair.static final ConverterFactoryConversion frompkl.base#Stringto Java Enum type. -
Method Summary
-
Field Details
-
pNullToAny
Conversion frompkl.base#Nullto any non-primitive type. The conversion result is alwaysnull. -
pObjectToPObject
Identity conversion forPObject. -
pStringToEnum
Conversion frompkl.base#Stringto 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 valueHOUSE_OF_CARDS. -
pAnyToOptional
Conversion from any Pkl value toOptional. Returns an empty optional forpkl.base#Nulland a present optional otherwise. -
pCollectionToArray
Conversion frompkl.base#Collectionto Java primitive or object array. -
pCollectionToCollection
Conversion frompkl.base#CollectiontoCollection. The concrete implementation type is determined usingTypeMappings. -
pMapToMap
Conversion frompkl.base#MaptoMap. The concrete implementation type is determined usingTypeMappings. -
pObjectToDataObject
Conversion from Pkl module or object to Java data object. The conversion is performed as follows:- Find the Java class constructor with the highest number of parameters.
- Correlate constructor parameters with Pkl object properties by name.
- Convert each Pkl property value to the corresponding constructor parameter's type.
- 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
-parametersis set, constructor parameters must be annotated withNamedorjavax.inject.Named. -
pObjectToMap
-
pPairToPair
Conversion frompkl.base#PairtoPair. -
all
All conversions defined in this class.
-