public class LongCounter
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
| Modifier and Type | Class and Description |
|---|---|
private static class |
LongCounter.Wrapper
Base wrapper class for other wrappers.
|
| Modifier and Type | Field and Description |
|---|---|
private long |
count
The current count
|
private static long |
serialVersionUID
The serialVersionUID
|
| Constructor and Description |
|---|
LongCounter()
Construct a LongCounter.
|
LongCounter(long count)
Construct a LongCounter with a starting value.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Return a cloned copy of this object.
|
long |
decrement()
Decrement the counter.
|
boolean |
equals(java.lang.Object obj)
Check if the given object is equal to this.
|
long |
getCount()
Return the current value of the counter.
|
long |
increment()
Increment the counter.
|
static LongCounter |
makeDirectional(LongCounter counter,
boolean increasing)
Returns a directional counter.
|
static LongCounter |
makeSynchronized(LongCounter counter)
Return a synchronized counter.
|
void |
reset()
Reset the counter to zero.
|
java.lang.String |
toString()
Return a string representation of this.
|
private static final long serialVersionUID
private long count
public LongCounter(long count)
count - Starting value for counter.public LongCounter()
public long increment()
public long decrement()
public long getCount()
public void reset()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - Object to test equality with.public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Object clone()
clone in class java.lang.Objectpublic static LongCounter makeSynchronized(LongCounter counter)
counter - LongCounter to synchronize.public static LongCounter makeDirectional(LongCounter counter, boolean increasing)
counter - LongCounter to make directional.increasing - True to create an increasing only
or false to create a decreasing only.