public final class MutableLong extends Number implements Comparable<MutableLong>, 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 mutablelong wrapper.
Note that as MutableLong does not extend Long, it is not treated by String.format as a Long parameter.
MutableLong is NOT thread-safe.
Long,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
void |
add(long operand)
Adds a value to the value of this instance.
|
long |
addAndGet(long delta)
Adds the given value to the current value.
|
int |
compareTo(MutableLong other)
Compares this mutable to another in ascending order.
|
void |
decrement()
Decrements the value.
|
long |
decrementAndGet()
Decrements by one the current value.
|
double |
doubleValue()
Returns the value of this MutableLong as a double.
|
boolean |
equals(Object obj)
Compares this object to the specified object.
|
float |
floatValue()
Returns the value of this MutableLong as a float.
|
long |
getAndAdd(long delta)
Adds the given value to the current value.
|
long |
getAndDecrement()
Decrements by one the current value.
|
long |
getAndIncrement()
Increments by one the current value.
|
long |
getAndSet(long value)
Gets the and set.
|
long |
getValue()
Deprecated.
replace by
value(). |
int |
hashCode()
Returns a suitable hash code for this mutable.
|
void |
increment()
Increments the value.
|
long |
incrementAndGet()
Increments by one the current value.
|
int |
intValue()
Returns the value of this MutableLong as an int.
|
long |
longValue()
Returns the value of this MutableLong as a long.
|
static MutableLong |
of(long value) |
long |
setAndGet(long value)
Sets the and get.
|
<E extends Exception> |
setIf(long newValue,
Throwables.LongBiPredicate<E> predicate)
Deprecated.
|
<E extends Exception> |
setIf(long newValue,
Throwables.LongPredicate<E> predicate)
Set with the specified new value and returns
true if predicate returns true. |
void |
setValue(long value)
Sets the value.
|
void |
subtract(long operand)
Subtracts a value from the value of this instance.
|
String |
toString()
Returns the String value of this mutable.
|
long |
value() |
byteValue, shortValuepublic static MutableLong of(long value)
value - public long value()
@Deprecated public long getValue()
value().public void setValue(long value)
public long getAndSet(long value)
value - public long setAndGet(long value)
value - public <E extends Exception> boolean setIf(long newValue, Throwables.LongPredicate<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(long newValue, Throwables.LongBiPredicate<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(long operand)
public void subtract(long operand)
public final long getAndIncrement()
public final long getAndDecrement()
public final long incrementAndGet()
public final long decrementAndGet()
public final long getAndAdd(long delta)
delta - the value to addpublic final long addAndGet(long 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(MutableLong other)
compareTo in interface Comparable<MutableLong>public boolean equals(Object obj)
true if and only if the argument
is not null and is a MutableLong object that contains the same long
value as this object.
obj the object to compare with, null returns falsepublic int hashCode()
Copyright © 2021. All rights reserved.