类 NumberMorpher

java.lang.Object
com.sh.json.ezmorph.object.AbstractObjectMorpher
com.sh.json.ezmorph.object.NumberMorpher
所有已实现的接口:
Morpher, ObjectMorpher

public final class NumberMorpher extends AbstractObjectMorpher
Morphs to a subclass of Number.
Supported types are - Byte, Short, Integer, Long, Float, BigInteger, BigtDecimal.
  • 构造器详细资料

    • NumberMorpher

      public NumberMorpher(Class<?> type)
      Creates a new morpher for the target type.
      参数:
      type - must be a primitive or wrapper type. BigDecimal and BigInteger are also supported.
    • NumberMorpher

      public NumberMorpher(Class<?> type, Number defaultValue)
      Creates a new morpher for the target type with a default value.
      The defaultValue should be of the same class as the target type.
      参数:
      type - must be a primitive or wrapper type. BigDecimal and BigInteger are also supported.
      defaultValue - return value if the value to be morphed is null
  • 方法详细资料

    • equals

      public boolean equals(Object obj)
      覆盖:
      equals 在类中 Object
    • getDefaultValue

      public Number getDefaultValue()
      Returns the default value for this Morpher.
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 Object
    • morph

      public Object morph(Object value)
      从接口复制的说明: ObjectMorpher
      Morphs the input object into an output object of the supported type.
      参数:
      value - The input value to be morphed
    • morphsTo

      public Class<?> morphsTo()
      从接口复制的说明: Morpher
      Returns the target Class for conversion.
      返回:
      the target Class for conversion.
    • setDefaultValue

      public void setDefaultValue(Number defaultValue)
      Sets the defaultValue to use if the value to be morphed is null.
      The defaultValue should be of the same class as the type this morpher returns with morphsTo().
      参数:
      defaultValue - return value if the value to be morphed is null