public interface Counter
Depending on the usage it comes in a
thread-safe implementation
and a non thread-safe implementation
.
There are also factories for both counters:
SIMPLE
and THREAD_SAFE
.
Modifier and Type | Interface and Description |
---|---|
static interface |
Counter.Creator
Deprecated.
outdated, use
Supplier<Counter> instead |
Modifier and Type | Field and Description |
---|---|
static java.util.function.Supplier<Counter> |
SIMPLE
Simple counter creator.
|
static java.util.function.Supplier<Counter> |
THREAD_SAFE
Thread safe counter creator.
|
Modifier and Type | Method and Description |
---|---|
int |
add(Counter counter)
Add something to the counter.
|
int |
add(int add)
Add something to the counter.
|
default int |
add(java.lang.Number number)
Add a number to the counter.
|
int |
add1()
Add 1 to counter.
|
int |
getValue()
Get the value.
|
void |
setValue(int value)
Set the value.
|
static Counter |
simple()
Factory method for creating a simple non-thread-safe counter.
|
static Counter |
simple(int initial)
Factory method for creating a simple non-thread-safe counter.
|
default int |
substract(Counter counter)
Deprecated.
bad English, use
subtract(Counter) |
default int |
substract(int sub)
Deprecated.
bad English, use
subtract(int) |
default int |
substract1()
Deprecated.
bad English, use
subtract1() |
int |
subtract(Counter counter)
Subtract something from the counter.
|
int |
subtract(int sub)
Subtract something from the counter.
|
default int |
subtract(java.lang.Number number)
Subtract a number to the counter.
|
int |
subtract1()
Subtract 1 from counter.
|
static Counter |
threadSafe()
Factory method for creating a thread-safe counter.
|
static Counter |
threadSafe(int initial)
Factory method for creating a thread-safe counter.
|
static final java.util.function.Supplier<Counter> SIMPLE
simple()
.SimpleCounter
static final java.util.function.Supplier<Counter> THREAD_SAFE
threadSafe()
.ThreadSafeCounter
int add(int add)
add
- value to addint add(@NotNull Counter counter)
counter
- counter which value is addeddefault int add(@NotNull java.lang.Number number)
number
- number to add, treated as an integer valueint add1()
int subtract(int sub)
sub
- value to subtract@Deprecated default int substract(int sub)
subtract(int)
sub
- value to subtractint subtract(@NotNull Counter counter)
counter
- counter which value is subtracted@Deprecated default int substract(@NotNull Counter counter)
subtract(Counter)
counter
- counter which value is subtracteddefault int subtract(@NotNull java.lang.Number number)
number
- number to add, treated as an integer valueint subtract1()
@Deprecated default int substract1()
subtract1()
int getValue()
void setValue(int value)
value
- new value@NotNull static Counter simple()
0
@NotNull static Counter simple(int initial)
initial
- initial value of counter@NotNull static Counter threadSafe()
0