public final class MutableLong extends java.lang.Number implements java.lang.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.
Long
,
Serialized FormModifier 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(java.lang.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) |
long |
getValue()
Gets the value as a Long instance.
|
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) |
<E extends java.lang.Exception> |
setIf(long newValue,
Try.LongBiPredicate<E> predicate)
Set with the specified new value and returns
true if predicate returns true. |
<E extends java.lang.Exception> |
setIf(long newValue,
Try.LongPredicate<E> predicate)
Set with the specified new value and returns
true if predicate returns true. |
MutableLong |
setValue(long value)
Sets the value.
|
void |
subtract(long operand)
Subtracts a value from the value of this instance.
|
java.lang.String |
toString()
Returns the String value of this mutable.
|
long |
value() |
public static MutableLong of(long value)
public long value()
public long getValue()
public MutableLong setValue(long value)
value
- the value to setpublic long getAndSet(long value)
public long setAndGet(long value)
public <E extends java.lang.Exception> boolean setIf(long newValue, Try.LongPredicate<E> predicate) throws E extends java.lang.Exception
true
if predicate
returns true.
Otherwise just return false
without setting the value to new value.newValue
- predicate
- - test the current value.E extends java.lang.Exception
public <E extends java.lang.Exception> boolean setIf(long newValue, Try.LongBiPredicate<E> predicate) throws E extends java.lang.Exception
true
if predicate
returns true.
Otherwise just return false
without setting the value to new value.newValue
- predicate
- the first parameter is the current value, the second parameter is the new value.E extends java.lang.Exception
public void increment()
public void decrement()
public void add(long operand)
operand
- the value to add, not nullpublic void subtract(long operand)
operand
- the value to subtract, not nullpublic 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()
intValue
in class java.lang.Number
public long longValue()
longValue
in class java.lang.Number
public float floatValue()
floatValue
in class java.lang.Number
public double doubleValue()
doubleValue
in class java.lang.Number
public int compareTo(MutableLong other)
compareTo
in interface java.lang.Comparable<MutableLong>
other
- the other mutable to compare to, not nullpublic boolean equals(java.lang.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.equals
in class java.lang.Object
obj
- the object to compare with, null returns falsetrue
if the objects are the same; false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object