Package com.gengoai.conversion
Class BaseNumberTypeConverter
- java.lang.Object
-
- com.gengoai.conversion.BaseNumberTypeConverter
-
- All Implemented Interfaces:
TypeConverter
- Direct Known Subclasses:
BigDecimalTypeConverter
,BigIntegerTypeConverter
,ByteTypeConverter
,DoubleTypeConverter
,FloatTypeConverter
,IntegerTypeConverter
,LongTypeConverter
,ShortTypeConverter
public abstract class BaseNumberTypeConverter extends Object implements TypeConverter
Base class for converter objects to numbers. The following types are supported.JsonEntry
can be converted if it is a primitive- Numbers
- Booleans are converted to 1 or 0
- Characters are converted to their integer values
- Other objects are converted to Strings and the class attempts to parse the strings in various formats.
- Author:
- David B. Bracewell
-
-
Constructor Summary
Constructors Constructor Description BaseNumberTypeConverter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Object
convert(Object object, Type... parameters)
Converts an object from one type to another.protected abstract Object
convertNumber(Number number)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.gengoai.conversion.TypeConverter
getConversionType
-
-
-
-
Method Detail
-
convert
public final Object convert(Object object, Type... parameters) throws TypeConversionException
Description copied from interface:TypeConverter
Converts an object from one type to another.- Specified by:
convert
in interfaceTypeConverter
- Parameters:
object
- the source objectparameters
- the optional type parameters when using Generics.- Returns:
- the converted object
- Throws:
TypeConversionException
- the source object was not able to be converted to the target type
-
-