Class IntegerMutable

java.lang.Object
info.monitorenter.util.math.IntegerMutable

public class IntegerMutable extends Object
Mutable Integer.

I needed an wrapper of an primitive int to share the same value between different instances and to have the changes made to the primitive value take effect on all owners of the same instance.

What a pity that java.lang.Integer does not allow to change it's internal value at runtime. Every time a new Integer has to be constructed.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The largest value of type int.
    static final int
    The smallest value of type int.
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntegerMutable(int value)
    Constructs a newly allocated Integer object that represents the primitive int argument.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int i)
    Adds the given value to the internal value.
    void
    Adds the given value to the internal value.
    void
    Adds the given value to the internal value.
    boolean
     
    int
    Returns the value as an int.
    int
     
    int
    Returns the value as an int.
    void
    setValue(int value)
    Sets the value.
    void
    sub(int i)
    Substracts the given value from the internal value.
    void
    Substracts the given value from the internal value.
    void
    Substracts the given value from the internal value.
    Returns a String object representing this Integer's value.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • MAX_VALUE

      public static final int MAX_VALUE
      The largest value of type int. The constant value of this field is 2147483647.
      See Also:
    • MIN_VALUE

      public static final int MIN_VALUE
      The smallest value of type int. The constant value of this field is -2147483648.
      See Also:
  • Constructor Details

    • IntegerMutable

      public IntegerMutable(int value)
      Constructs a newly allocated Integer object that represents the primitive int argument.
      Parameters:
      value - the value to be represented by the Integer.
  • Method Details