Package io.micronaut.core.convert.format
Class ReadableBytesTypeConverter
java.lang.Object
io.micronaut.core.convert.format.ReadableBytesTypeConverter
- All Implemented Interfaces:
FormattingTypeConverter<CharSequence,
,Number, ReadableBytes> TypeConverter<CharSequence,
Number>
public class ReadableBytesTypeConverter
extends Object
implements FormattingTypeConverter<CharSequence,Number,ReadableBytes>
Converts String's to readable bytes.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionconvert
(CharSequence object, Class<Number> 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
-
ReadableBytesTypeConverter
public ReadableBytesTypeConverter()
-
-
Method Details
-
annotationType
- Specified by:
annotationType
in interfaceFormattingTypeConverter<CharSequence,
Number, ReadableBytes> - Returns:
- The annotation type for this formatter
-
convert
public Optional<Number> convert(CharSequence object, Class<Number> 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,
Number> - Parameters:
object
- The object typetargetType
- The target type being converted tocontext
- TheConversionContext
- Returns:
- The converted type or empty if the conversion is not possible
-