Package org.pkl.config.java.mapper
Class ValueMapperBuilder
java.lang.Object
org.pkl.config.java.mapper.ValueMapperBuilder
Builds a
ValueMapper configured with appropriate conversions, converter factories, and
type mappings.-
Method Summary
Modifier and TypeMethodDescriptionaddConversion(Conversion<?, ?> conversion) Adds the given conversion.addConversions(Collection<Conversion<?, ?>> conversions) Adds the given conversions.addConverterFactories(Collection<ConverterFactory> factories) Adds the given converter factories.addConverterFactory(ConverterFactory factory) Adds the given converter factory.addTypeMapping(TypeMapping<?, ?> mapping) Adds the given type mapping.addTypeMappings(Collection<TypeMapping<?, ?>> mappings) Adds the given type mappings.build()Builds a mapper with the configured conversions, converter factories, and type mappings.List<Conversion<?, ?>> Returns the currently set conversions.Returns the currently set converter factories.List<TypeMapping<?, ?>> Returns the currently set type mappings.static ValueMapperBuilderCreates a builder preconfigured with all conversions, converter factories, and type mappings defined in this module.setConversions(Collection<Conversion<?, ?>> conversions) Removes any existing conversions, then adds the given conversions.setConverterFactories(Collection<ConverterFactory> factories) Removes any existing converter factories, then adds the given factories.setTypeMappings(Collection<TypeMapping<?, ?>> mappings) Removes any existing type mappings, then adds the given mappings.static ValueMapperBuilderCreates a builder without any preconfigured conversions, converter factories, or type mappings.
-
Method Details
-
unconfigured
Creates a builder without any preconfigured conversions, converter factories, or type mappings.- Returns:
- a builder without any preconfigured conversions, converter factories, or type mappings
-
preconfigured
Creates a builder preconfigured with all conversions, converter factories, and type mappings defined in this module.- Returns:
- a builder preconfigured with all conversions, converter factories, and type mappings defined in this module
-
addConversion
Adds the given conversion. For conversions to a primitive type, a conversion to the corresponding wrapper type is automatically added.- Parameters:
conversion- the conversion to be added- Returns:
- this
-
addConversions
Adds the given conversions. For conversions to a primitive type, a conversion to the corresponding wrapper type is automatically added.- Parameters:
conversions- the conversions to be added- Returns:
- this
-
setConversions
Removes any existing conversions, then adds the given conversions. -
getConversions
Returns the currently set conversions. -
addConverterFactory
Adds the given converter factory. Factories will be queried for converters in the same order as they are being added to this builder.- Parameters:
factory- the converter factory to be added- Returns:
- this
-
addConverterFactories
Adds the given converter factories. Factories will be queried for converters in the same order as they are being added to this builder.- Parameters:
factories- the converter factories to be added- Returns:
- this
-
setConverterFactories
Removes any existing converter factories, then adds the given factories. -
getConverterFactories
Returns the currently set converter factories. -
addTypeMapping
Adds the given type mapping.- Parameters:
mapping- the type mapping to be added- Returns:
- this
-
addTypeMappings
Adds the given type mappings.- Parameters:
mappings- the type mappings to be added- Returns:
- this
-
setTypeMappings
Removes any existing type mappings, then adds the given mappings. -
getTypeMappings
Returns the currently set type mappings. -
build
Builds a mapper with the configured conversions, converter factories, and type mappings. If desired, the same builder can be used to build multiple mappers.- Returns:
- a mapper with the configured conversions, converter factories, and type mappings
-