- All Known Implementing Classes:
ObjectConfigMapperProvider
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Provides mapping functions that convert a
Config
subtree to specific Java types.
The config system automatically loads ConfigMapperProviders using the
Java ServiceLoader mechanism, and by default the config
system automatically registers all ConfigMappers from all such
providers with every Config.Builder. The application can suppress
auto-registration of loaded mappers by invoking
Config.Builder.disableMapperServices().
Each ConfigMapperProvider can specify a
Weight. The default weight is 100.0.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault Map<GenericType<?>, BiFunction<Config, ConfigMapper, ?>> Returns a map of mapper functions associated with appropriate target type (GenericType<?>.default <T> Optional<BiFunction<Config, ConfigMapper, T>> mapper(GenericType<T> type) Mapper for a specific generic type.A simple mapping function from config node to a typed value based on the expected class.mappers()Returns a map of mapper functions associated with appropriate target type (Class<?>.
-
Method Details
-
mappers
Returns a map of mapper functions associated with appropriate target type (Class<?>.Mappers will be automatically registered by
Config.Builderduring bootstrapping ofConfigunlessdisableld.- Returns:
- a map of config mapper functions, never
null, though this may return an empty map ifmapper(Class)is used instead
-
genericTypeMappers
Returns a map of mapper functions associated with appropriate target type (GenericType<?>.Mappers will be automatically registered by
Config.Builderduring bootstrapping ofConfigunlessdisableld.- Returns:
- a map of config mapper functions, never
null, though this may return an empty map ifmapper(Class)is used instead
-
mapper
A simple mapping function from config node to a typed value based on the expected class. If more complex type handling or conversion is needed, usemapper(GenericType).- Type Parameters:
T- type returned from conversion- Parameters:
type- type of the expected mapping result- Returns:
- function to convert config node to the expected type, or empty if the type is not supported by this provider
-
mapper
Mapper for a specific generic type. If your mapper only supports simple classes, get it usingGenericType.rawType(). Otherwise, you have access to the (possibly) generics type of the expected result usingGenericType.type().The mapping function has two parameters:
Config- config node to convert to the expected typeConfigMapper- mapper to help with conversion of sub-nodes if needed
- Type Parameters:
T- type to map to- Parameters:
type- type providing information what is the mapped type- Returns:
- a function that would convert the provided Config instance into the expected type if supported by this provider, empty otherwise.
-