类 ToNumberConversion

    • 构造器详细资料

      • ToNumberConversion

        public ToNumberConversion()
    • 方法详细资料

      • 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)
        内部的转换,用于子类继承拓展
      • toBigDecimal

        protected BigDecimal toBigDecimal​(Object value)
        转换为BigDecimal
        如果给定的值为空,或者转换失败,返回默认值
        转换失败不会报错
        参数:
        value - 被转换的值
        返回:
        结果
      • toBigInteger

        protected BigInteger toBigInteger​(Object value)
        转换为BigInteger
        如果给定的值为空,或者转换失败,返回默认值
        转换失败不会报错
        参数:
        value - 被转换的值
        返回:
        结果