Package io.micronaut.core.convert
Interface MutableConversionService
- All Superinterfaces:
ConversionService
- All Known Subinterfaces:
Environment
- All Known Implementing Classes:
DefaultEnvironment
,DefaultMutableConversionService
A version of
ConversionService
that supports adding new converters.- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Field Summary
Fields inherited from interface io.micronaut.core.convert.ConversionService
SHARED
-
Method Summary
Modifier and TypeMethodDescription<S,
T> void addConverter
(@NonNull Class<S> sourceType, @NonNull Class<T> targetType, @NonNull TypeConverter<S, T> typeConverter) Adds a type converter.<S,
T> void addConverter
(@NonNull Class<S> sourceType, @NonNull Class<T> targetType, @NonNull Function<S, T> typeConverter) Adds a type converter.static @NonNull MutableConversionService
create()
Creates a new mutable conversion service that extends the shared conversion service.Methods inherited from interface io.micronaut.core.convert.ConversionService
canConvert, convert, convert, convert, convert, convertRequired, convertRequired, convertRequired
-
Method Details
-
create
Creates a new mutable conversion service that extends the shared conversion service. In most cases the mutable service from the bean context should be used.- Returns:
- A new mutable conversion service.
-
addConverter
<S,T> void addConverter(@NonNull @NonNull Class<S> sourceType, @NonNull @NonNull Class<T> targetType, @NonNull @NonNull Function<S, T> typeConverter) Adds a type converter.- Type Parameters:
S
- The source generic typeT
- The target generic type- Parameters:
sourceType
- The source typetargetType
- The target typetypeConverter
- The type converter
-
addConverter
<S,T> void addConverter(@NonNull @NonNull Class<S> sourceType, @NonNull @NonNull Class<T> targetType, @NonNull @NonNull TypeConverter<S, T> typeConverter) Adds a type converter.- Type Parameters:
S
- The source generic typeT
- The target generic type- Parameters:
sourceType
- The source typetargetType
- The target typetypeConverter
- The type converter
-