类 ToNumberConversion
- java.lang.Object
-
- cc.shacocloud.mirage.utils.converter.support.AbstractConversion
-
- cc.shacocloud.mirage.utils.converter.support.ToNumberConversion
-
- 所有已实现的接口:
Ordered,Conversion,ConversionSupport
public class ToNumberConversion extends AbstractConversion implements ConversionSupport
转换为Number类型的转换器- 作者:
- 思追(shaco)
-
-
字段概要
-
从接口继承的字段 cc.shacocloud.mirage.utils.comparator.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
-
构造器概要
构造器 构造器 说明 ToNumberConversion()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Objectconvert(@NotNull Object source, @NotNull TypeDescriptor sourceType, @NotNull TypeDescriptor targetType)将源对象转换为TypeDescriptor描述的目标类型protected @Nullable Numberconvert(@NotNull Object source, Class<? extends Number> targetType)转换对象为数字,支持的对象包括:protected StringconvertToStr(Object value)数值转换为字符串考虑结尾类型标识protected NumberinternalConvert(@NotNull Object source, @NotNull TypeDescriptor sourceType, @NotNull TypeDescriptor targetType)内部的转换,用于子类继承拓展booleansupport(@NotNull TypeDescriptor sourceType, @NotNull TypeDescriptor targetType)判断是否可以将源对象类型转换为TypeDescriptor描述的目标类型protected BigDecimaltoBigDecimal(Object value)转换为BigDecimal
如果给定的值为空,或者转换失败,返回默认值
转换失败不会报错protected BigIntegertoBigInteger(Object value)转换为BigInteger
如果给定的值为空,或者转换失败,返回默认值
转换失败不会报错-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 cc.shacocloud.mirage.utils.converter.ConversionSupport
getOrder
-
-
-
-
方法详细资料
-
support
public boolean support(@NotNull @NotNull TypeDescriptor sourceType, @NotNull @NotNull TypeDescriptor targetType)从接口复制的说明:ConversionSupport判断是否可以将源对象类型转换为TypeDescriptor描述的目标类型- 指定者:
support在接口中ConversionSupport- 参数:
sourceType- 要从中转换的字段的类型描述符targetType- 要转换为的字段的类型描述符- 返回:
- the converted object
-
convert
public Object convert(@NotNull @NotNull Object source, @NotNull @NotNull TypeDescriptor sourceType, @NotNull @NotNull TypeDescriptor targetType)
从接口复制的说明:Conversion将源对象转换为TypeDescriptor描述的目标类型- 指定者:
convert在接口中Conversion- 参数:
source- 要转换的源对象(可以是null)sourceType- 要从中转换的字段的类型描述符targetType- 要转换为的字段的类型描述符- 返回:
- the converted object
-
convert
@Nullable protected @Nullable Number convert(@NotNull @NotNull Object source, Class<? extends Number> targetType)
转换对象为数字,支持的对象包括:- 参数:
source- 源对象值targetType- 目标的数字类型- 返回:
- 转换后的数字
-
internalConvert
protected Number internalConvert(@NotNull @NotNull Object source, @NotNull @NotNull TypeDescriptor sourceType, @NotNull @NotNull TypeDescriptor targetType)
内部的转换,用于子类继承拓展
-
convertToStr
protected String convertToStr(Object value)
数值转换为字符串考虑结尾类型标识- 覆盖:
convertToStr在类中AbstractConversion- 参数:
value- 值
-
toBigDecimal
protected BigDecimal toBigDecimal(Object value)
转换为BigDecimal
如果给定的值为空,或者转换失败,返回默认值
转换失败不会报错- 参数:
value- 被转换的值- 返回:
- 结果
-
toBigInteger
protected BigInteger toBigInteger(Object value)
转换为BigInteger
如果给定的值为空,或者转换失败,返回默认值
转换失败不会报错- 参数:
value- 被转换的值- 返回:
- 结果
-
-