Package org.pkl.config.java.mapper
Interface ConverterFactory
-
- All Known Implementing Classes:
PObjectToDataObject,PObjectToMap
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ConverterFactoryA factory forConverters. Used to implement conversions to generic Java classes. In such a case a singleConverterdoes not suffice. Instead the factory creates a new converter for every parameterization of the target type. Once created, the converter is cached for later use, and the factory is never again invoked for the same parameterized target type.For best performace, all introspection of target types (for example using
Reflection) should happen in the factory rather then the returned converters.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Optional<Converter<?,?>>create(org.pkl.core.PClassInfo<?> sourceType, java.lang.reflect.Type targetType)Returns a converter for the given source and target types, orOptional.empty()if the factory cannot handle the requested types.default ConverterFactorywhen(java.util.function.Predicate<java.lang.reflect.Type> predicate)Returns a new factory that restricts use of this factory to target types for which the given predicate holds.
-
-
-
Method Detail
-
create
java.util.Optional<Converter<?,?>> create(org.pkl.core.PClassInfo<?> sourceType, java.lang.reflect.Type targetType)
Returns a converter for the given source and target types, orOptional.empty()if the factory cannot handle the requested types.
-
when
default ConverterFactory when(java.util.function.Predicate<java.lang.reflect.Type> predicate)
Returns a new factory that restricts use of this factory to target types for which the given predicate holds.
-
-