Class MutableShort

java.lang.Object
java.lang.Number
com.luna.common.mutable.MutableShort
All Implemented Interfaces:
Mutable<Number>, Serializable, Comparable<MutableShort>

public class MutableShort extends Number implements Comparable<MutableShort>, Mutable<Number>
可变 short 类型
Since:
3.0.1
See Also:
  • Constructor Details

    • MutableShort

      public MutableShort()
      构造,默认值0
    • MutableShort

      public MutableShort(short value)
      构造
      Parameters:
      value - 值
    • MutableShort

      public MutableShort(Number value)
      构造
      Parameters:
      value - 值
    • MutableShort

      public MutableShort(String value) throws NumberFormatException
      构造
      Parameters:
      value - String值
      Throws:
      NumberFormatException - 转为Short错误
  • Method Details

    • get

      public Short get()
      Description copied from interface: Mutable
      获得原始值
      Specified by:
      get in interface Mutable<Number>
      Returns:
      原始值
    • set

      public void set(short value)
      设置值
      Parameters:
      value - 值
    • set

      public void set(Number value)
      Description copied from interface: Mutable
      设置值
      Specified by:
      set in interface Mutable<Number>
      Parameters:
      value - 值
    • increment

      public MutableShort increment()
      值+1
      Returns:
      this
    • decrement

      public MutableShort decrement()
      值减一
      Returns:
      this
    • add

      public MutableShort add(short operand)
      增加值
      Parameters:
      operand - 被增加的值
      Returns:
      this
    • add

      public MutableShort add(Number operand)
      增加值
      Parameters:
      operand - 被增加的值,非空
      Returns:
      this
      Throws:
      NullPointerException - if the object is null
    • subtract

      public MutableShort subtract(short operand)
      减去值
      Parameters:
      operand - 被减的值
      Returns:
      this
    • subtract

      public MutableShort subtract(Number operand)
      减去值
      Parameters:
      operand - 被减的值,非空
      Returns:
      this
      Throws:
      NullPointerException - if the object is null
    • shortValue

      public short shortValue()
      Overrides:
      shortValue in class Number
    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • equals

      public boolean equals(Object obj)
      相等需同时满足如下条件:
      1. 非空
      2. 类型为 MutableShort
      3. 值相等
      Overrides:
      equals in class Object
      Parameters:
      obj - 比对的对象
      Returns:
      相同返回true,否则 false
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(MutableShort other)
      比较
      Specified by:
      compareTo in interface Comparable<MutableShort>
      Parameters:
      other - 其它 MutableShort 对象
      Returns:
      x==y返回0,x<y返回-1,x>y返回1
    • toString

      public String toString()
      Overrides:
      toString in class Object