public final class SimpleLongCounter extends java.lang.Object implements LongCounter
This class is not thread safe, see ThreadSafeLongCounter
for a thread safe counter!
LongCounter.Creator
SIMPLE, THREAD_SAFE
Constructor and Description |
---|
SimpleLongCounter()
Default constructor.
|
SimpleLongCounter(int val)
Constructor.
|
SimpleLongCounter(LongCounter count)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
add(long add)
Add something to the counter.
|
long |
add(LongCounter counter)
Add something to the counter.
|
long |
add1()
Add 1 to counter.
|
long |
getValue()
Get the value.
|
void |
setValue(long value)
Set the value.
|
long |
subtract(long sub)
Subtract something from the counter.
|
long |
subtract(LongCounter counter)
Subtract something from the counter.
|
long |
subtract1()
Subtract 1 from counter.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, add, subtract, subtract
public SimpleLongCounter()
public SimpleLongCounter(int val)
val
.val
- init valuepublic SimpleLongCounter(@NotNull LongCounter count)
count
- counter to be copiedpublic long add(long add)
LongCounter
add
in interface LongCounter
add
- value to addpublic long add(@NotNull LongCounter counter)
LongCounter
add
in interface LongCounter
counter
- counter which value is addedpublic long add1()
LongCounter
add1
in interface LongCounter
public long subtract(long sub)
LongCounter
subtract
in interface LongCounter
sub
- value to subtractpublic long subtract(@NotNull LongCounter counter)
LongCounter
subtract
in interface LongCounter
counter
- counter which value is subtractedpublic long subtract1()
LongCounter
subtract1
in interface LongCounter
public long getValue()
LongCounter
getValue
in interface LongCounter
public void setValue(long value)
LongCounter
setValue
in interface LongCounter
value
- new value@NotNull public java.lang.String toString()
toString
in class java.lang.Object