Package io.micronaut.core.convert
Class CharSequenceToEnumConverter<T extends Enum<T>>
java.lang.Object
io.micronaut.core.convert.CharSequenceToEnumConverter<T>
- Type Parameters:
T
- T The enum type
- All Implemented Interfaces:
TypeConverter<CharSequence,
T>
@Internal
public final class CharSequenceToEnumConverter<T extends Enum<T>>
extends Object
implements TypeConverter<CharSequence,T>
The converter that converts
CharSequence
to an enum.- Since:
- 4.2.0
- Author:
- Denis Stepanov
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvert
(CharSequence charSequence, Class<T> targetType, ConversionContext context) Converts from the given source object type to the target type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.convert.TypeConverter
convert
-
Constructor Details
-
CharSequenceToEnumConverter
public CharSequenceToEnumConverter()
-
-
Method Details
-
convert
public Optional<T> convert(CharSequence charSequence, Class<T> targetType, ConversionContext context) Description copied from interface:TypeConverter
Converts from the given source object type to the target type. Implementers should take care to returnOptional.empty()
in case the object is not convertible by catching any necessary exceptions and failing gracefully.- Specified by:
convert
in interfaceTypeConverter<CharSequence,
T extends Enum<T>> - Parameters:
charSequence
- The object typetargetType
- The target type being converted tocontext
- TheConversionContext
- Returns:
- The converted type or empty if the conversion is not possible
-