Package 

Class MutableInt

  • All Implemented Interfaces:
    external.org.apache.commons.lang3.mutable.Mutable , java.io.Serializable , java.lang.Comparable

    
    public class MutableInt
    extends Number implements Comparable<MutableInt>, Mutable<Number>
                        

    A mutable int wrapper.

    Note that as MutableInt does not extend Integer, it is not treated by String.format as an Integer parameter.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int value
    • Constructor Summary

      Constructors 
      Constructor Description
      MutableInt() Constructs a new MutableInt with the default value of zero.
      MutableInt(int value) Constructs a new MutableInt with the specified value.
      MutableInt(Number value) Constructs a new MutableInt with the specified value.
      MutableInt(String value) Constructs a new MutableInt parsing the given string.
    • Method Summary

      Modifier and Type Method Description
      void setValue(int value) Sets the value.
      void increment() Increments the value.
      void decrement() Decrements the value.
      void add(int operand) Adds a value to the value of this instance.
      void add(Number operand) Adds a value to the value of this instance.
      void subtract(int operand) Subtracts a value from the value of this instance.
      void subtract(Number operand) Subtracts a value from the value of this instance.
      int intValue() Returns the value of this MutableInt as an int.
      long longValue() Returns the value of this MutableInt as a long.
      float floatValue() Returns the value of this MutableInt as a float.
      double doubleValue() Returns the value of this MutableInt as a double.
      Integer toInteger() Gets this mutable as an instance of Integer.
      boolean equals(Object obj) Compares this object to the specified object.
      int hashCode() Returns a suitable hash code for this mutable.
      int compareTo(MutableInt other) Compares this mutable to another in ascending order.
      String toString() Returns the String value of this mutable.
      • Methods inherited from class java.lang.Number

        byteValue, doubleValue, floatValue, intValue, longValue, shortValue
      • Methods inherited from class java.lang.Comparable

        compareTo
      • Methods inherited from class external.org.apache.commons.lang3.mutable.Mutable

        getValue, setValue
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MutableInt

        MutableInt()
        Constructs a new MutableInt with the default value of zero.
      • MutableInt

        MutableInt(int value)
        Constructs a new MutableInt with the specified value.
        Parameters:
        value - the initial value to store
      • MutableInt

        MutableInt(Number value)
        Constructs a new MutableInt with the specified value.
        Parameters:
        value - the initial value to store, not null
      • MutableInt

        MutableInt(String value)
        Constructs a new MutableInt parsing the given string.
        Parameters:
        value - the string to parse, not null
    • Method Detail

      • setValue

         void setValue(int value)

        Sets the value.

        Parameters:
        value - the value to set
      • increment

         void increment()

        Increments the value.

      • decrement

         void decrement()

        Decrements the value.

      • add

         void add(int operand)

        Adds a value to the value of this instance.

        Parameters:
        operand - the value to add, not null
      • add

         void add(Number operand)

        Adds a value to the value of this instance.

        Parameters:
        operand - the value to add, not null
      • subtract

         void subtract(int operand)

        Subtracts a value from the value of this instance.

        Parameters:
        operand - the value to subtract, not null
      • subtract

         void subtract(Number operand)

        Subtracts a value from the value of this instance.

        Parameters:
        operand - the value to subtract, not null
      • intValue

         int intValue()

        Returns the value of this MutableInt as an int.

      • longValue

         long longValue()

        Returns the value of this MutableInt as a long.

      • floatValue

         float floatValue()

        Returns the value of this MutableInt as a float.

      • doubleValue

         double doubleValue()

        Returns the value of this MutableInt as a double.

      • equals

         boolean equals(Object obj)

        Compares this object to the specified object. The result is true if and only if the argument isnot null and is a MutableInt object that contains the same int valueas this object.

        Parameters:
        obj - the object to compare with, null returns false
      • hashCode

         int hashCode()

        Returns a suitable hash code for this mutable.

      • compareTo

         int compareTo(MutableInt other)

        Compares this mutable to another in ascending order.

        Parameters:
        other - the other mutable to compare to, not null
      • toString

         String toString()

        Returns the String value of this mutable.