Package io.micronaut.core.convert.format
Class ReadableBytesTypeConverter
- java.lang.Object
-
- io.micronaut.core.convert.format.ReadableBytesTypeConverter
-
- All Implemented Interfaces:
FormattingTypeConverter<java.lang.CharSequence,java.lang.Number,ReadableBytes>
,TypeConverter<java.lang.CharSequence,java.lang.Number>
public class ReadableBytesTypeConverter extends java.lang.Object implements FormattingTypeConverter<java.lang.CharSequence,java.lang.Number,ReadableBytes>
Converts String's to readable bytes.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description ReadableBytesTypeConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<ReadableBytes>
annotationType()
java.util.Optional<java.lang.Number>
convert(java.lang.CharSequence object, java.lang.Class<java.lang.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
-
-
-
-
Method Detail
-
annotationType
public java.lang.Class<ReadableBytes> annotationType()
- Specified by:
annotationType
in interfaceFormattingTypeConverter<java.lang.CharSequence,java.lang.Number,ReadableBytes>
- Returns:
- The annotation type for this formatter
-
convert
public java.util.Optional<java.lang.Number> convert(java.lang.CharSequence object, java.lang.Class<java.lang.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<java.lang.CharSequence,java.lang.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
-
-