-
- 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
intwrapper.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 intvalue
-
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 voidsetValue(int value)Sets the value. voidincrement()Increments the value. voiddecrement()Decrements the value. voidadd(int operand)Adds a value to the value of this instance. voidadd(Number operand)Adds a value to the value of this instance. voidsubtract(int operand)Subtracts a value from the value of this instance. voidsubtract(Number operand)Subtracts a value from the value of this instance. intintValue()Returns the value of this MutableInt as an int. longlongValue()Returns the value of this MutableInt as a long. floatfloatValue()Returns the value of this MutableInt as a float. doubledoubleValue()Returns the value of this MutableInt as a double. IntegertoInteger()Gets this mutable as an instance of Integer. booleanequals(Object obj)Compares this object to the specified object. inthashCode()Returns a suitable hash code for this mutable. intcompareTo(MutableInt other)Compares this mutable to another in ascending order. StringtoString()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
trueif and only if the argument isnotnulland is aMutableIntobject that contains the sameintvalueas 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
-
-
-
-