public final class MutableInt extends Number implements Comparable<MutableInt>, Mutable
Note: it's copied from Apache Commons Lang developed at The Apache Software Foundation (http://www.apache.org/), or under the Apache License 2.0. The methods copied from other products/frameworks may be modified in this class.
A mutableint wrapper.
Note that as MutableInt does not extend Integer, it is not treated by String.format as an Integer parameter.
MutableInt is NOT thread-safe.
Integer,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
void |
add(int operand)
Adds a value to the value of this instance.
|
int |
addAndGet(int delta)
Adds the given value to the current value.
|
int |
compareTo(MutableInt other)
Compares this mutable to another in ascending order.
|
void |
decrement()
Decrements the value.
|
int |
decrementAndGet()
Decrements by one the current value.
|
double |
doubleValue()
Returns the value of this MutableInt as a double.
|
boolean |
equals(Object obj)
Compares this object to the specified object.
|
float |
floatValue()
Returns the value of this MutableInt as a float.
|
int |
getAndAdd(int delta)
Adds the given value to the current value.
|
int |
getAndDecrement()
Decrements by one the current value.
|
int |
getAndIncrement()
Increments by one the current value.
|
int |
getAndSet(int value)
Gets the and set.
|
int |
getValue()
Deprecated.
replace by
value(). |
int |
hashCode()
Returns a suitable hash code for this mutable.
|
void |
increment()
Increments the value.
|
int |
incrementAndGet()
Increments by one the current value.
|
int |
intValue()
Returns the value of this MutableInt as an int.
|
long |
longValue()
Returns the value of this MutableInt as a long.
|
static MutableInt |
of(int value) |
int |
setAndGet(int value)
Sets the and get.
|
<E extends Exception> |
setIf(int newValue,
Throwables.IntBiPredicate<E> predicate)
Deprecated.
|
<E extends Exception> |
setIf(int newValue,
Throwables.IntPredicate<E> predicate)
Set with the specified new value and returns
true if predicate returns true. |
void |
setValue(int value)
Sets the value.
|
void |
subtract(int operand)
Subtracts a value from the value of this instance.
|
String |
toString()
Returns the String value of this mutable.
|
int |
value() |
byteValue, shortValuepublic static MutableInt of(int value)
value - public int value()
@Deprecated public int getValue()
value().public void setValue(int value)
value - the value to setpublic int getAndSet(int value)
value - public int setAndGet(int value)
value - public <E extends Exception> boolean setIf(int newValue, Throwables.IntPredicate<E> predicate) throws E extends Exception
true if predicate returns true.
Otherwise just return false without setting the value to new value.E - newValue - predicate - - test the current value.E - the eE extends Exception@Deprecated public <E extends Exception> boolean setIf(int newValue, Throwables.IntBiPredicate<E> predicate) throws E extends Exception
true if predicate returns true.
Otherwise just return false without setting the value to new value.E - newValue - predicate - the first parameter is the current value, the second parameter is the new value.E - the eE extends Exceptionpublic void increment()
public void decrement()
public void add(int operand)
operand - the value to add, not nullpublic void subtract(int operand)
operand - the value to subtract, not nullpublic final int getAndIncrement()
public final int getAndDecrement()
public final int incrementAndGet()
public final int decrementAndGet()
public final int getAndAdd(int delta)
delta - the value to addpublic final int addAndGet(int delta)
delta - the value to addpublic int intValue()
public long longValue()
public float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic int compareTo(MutableInt other)
compareTo in interface Comparable<MutableInt>other - the other mutable to compare to, not nullpublic boolean equals(Object obj)
true if and only if the argument is
not null and is a MutableInt object that contains the same int value
as this object.public int hashCode()
Copyright © 2021. All rights reserved.