Package de.xima.fc.common.counter
Interface Counter.LongCounter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.xima.fc.common.counter.Counter
Counter.LongCounter
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
changeBy(long amount)
Changes the counter by the specific amount of units.default Long
changeByAndGet(long amount)
Changes the counter by the specific amount of units and returns the new value.default long
changeByAndGetLong(long amount)
Changes the counter by the given amount and returns the new value as a primitivelong
.default Long
current()
Get the current value of the counter.long
currentLong()
Gets the current value of the counter as a primitivelong
.default Long
decrementAndGet()
Decrements the counter by a single unit and returns the new value.default long
decrementAndGetLong()
Decrements the counter by a single unit and returns the new value as a primitivelong
.default com.google.common.collect.DiscreteDomain<Long>
domain()
Gets the domain discrete domain to which the counter value belongs.default Long
getAndChangeBy(long amount)
Gets the current value of the counter, then changes the counter by the specific amount of units.default long
getAndChangeByLong(long amount)
Gets the current value of the counter as a primitivelong
, then changes it by the given amount.default Long
getAndDecrement()
Gets the current value of the counter, then decrements the counter by a single unit.default long
getAndDecrementLong()
Gets the current value of the counter as a primitivelong
, then decrements it by a single unit.default Long
getAndIncrement()
Gets the current value of the counter, then increments the counter by a single unit.default long
getAndIncrementLong()
Gets the current value of the counter as a primitivelong
, then increments it by a single unit.default Long
incrementAndGet()
Increments the counter by a single unit and returns the new value.default long
incrementAndGetLong()
Increments the counter by a single unit and returns the new value as a primitivelong
.default void
set(Long value)
Sets the counter to a specific value.void
setLong(long value)
Sets the counter to a specific value, provided as a primitivelong
.
-
-
-
Method Detail
-
changeBy
default void changeBy(long amount)
Description copied from interface:Counter
Changes the counter by the specific amount of units. A positive amount increments the counter, a negative amount decrements the counter.The default implementation of this method is to increment or decrement the counter by repeatedly incrementing or decrementing the counter by a single unit via the domain until the desired amount is reached. Implementations are encouraged to override this method with a more efficient implementation if possible.
-
changeByAndGet
default Long changeByAndGet(long amount)
Description copied from interface:Counter
Changes the counter by the specific amount of units and returns the new value.- Specified by:
changeByAndGet
in interfaceCounter<Long>
- Parameters:
amount
- The amount to change the counter by.- Returns:
- The new value of the counter after it was changed.
-
changeByAndGetLong
default long changeByAndGetLong(long amount)
Changes the counter by the given amount and returns the new value as a primitivelong
.- Parameters:
amount
- The amount to change the counter by.- Returns:
- The new value of the counter after it was changed.
-
current
default Long current()
Description copied from interface:Counter
Get the current value of the counter.
-
currentLong
long currentLong()
Gets the current value of the counter as a primitivelong
.- Returns:
- The current value of the counter.
-
decrementAndGet
default Long decrementAndGet()
Description copied from interface:Counter
Decrements the counter by a single unit and returns the new value.- Specified by:
decrementAndGet
in interfaceCounter<Long>
- Returns:
- The new value of the counter after decrementing.
-
decrementAndGetLong
default long decrementAndGetLong()
Decrements the counter by a single unit and returns the new value as a primitivelong
.- Returns:
- The new value of the counter after decrementing.
-
domain
default com.google.common.collect.DiscreteDomain<Long> domain()
Description copied from interface:Counter
Gets the domain discrete domain to which the counter value belongs.
-
getAndChangeBy
default Long getAndChangeBy(long amount)
Description copied from interface:Counter
Gets the current value of the counter, then changes the counter by the specific amount of units.- Specified by:
getAndChangeBy
in interfaceCounter<Long>
- Parameters:
amount
- The amount to change the counter by.- Returns:
- The previous value of the counter.
-
getAndChangeByLong
default long getAndChangeByLong(long amount)
Gets the current value of the counter as a primitivelong
, then changes it by the given amount.- Parameters:
amount
- The amount to change the counter by.- Returns:
- The previous value of the counter.
-
getAndDecrement
default Long getAndDecrement()
Description copied from interface:Counter
Gets the current value of the counter, then decrements the counter by a single unit.- Specified by:
getAndDecrement
in interfaceCounter<Long>
- Returns:
- The previous value of the counter.
-
getAndDecrementLong
default long getAndDecrementLong()
Gets the current value of the counter as a primitivelong
, then decrements it by a single unit.- Returns:
- The previous value of the counter.
-
getAndIncrement
default Long getAndIncrement()
Description copied from interface:Counter
Gets the current value of the counter, then increments the counter by a single unit.- Specified by:
getAndIncrement
in interfaceCounter<Long>
- Returns:
- The previous value of the counter.
-
getAndIncrementLong
default long getAndIncrementLong()
Gets the current value of the counter as a primitivelong
, then increments it by a single unit.- Returns:
- The previous value of the counter.
-
incrementAndGet
default Long incrementAndGet()
Description copied from interface:Counter
Increments the counter by a single unit and returns the new value.- Specified by:
incrementAndGet
in interfaceCounter<Long>
- Returns:
- The new value of the counter after incrementing.
-
incrementAndGetLong
default long incrementAndGetLong()
Increments the counter by a single unit and returns the new value as a primitivelong
.- Returns:
- The new value of the counter after incrementing.
-
set
default void set(Long value)
Description copied from interface:Counter
Sets the counter to a specific value.
-
setLong
void setLong(long value)
Sets the counter to a specific value, provided as a primitivelong
.- Parameters:
value
- The value to set the counter to.
-
-