Interface Counter.LongCounter
- Enclosing interface:
Counter<T extends Comparable<T>>
-
Nested Class Summary
Nested classes/interfaces inherited from interface Counter
Counter.LongCounter -
Method Summary
Modifier and TypeMethodDescriptiondefault voidchangeBy(long amount) Changes the counter by the specific amount of units.default LongchangeByAndGet(long amount) Changes the counter by the specific amount of units and returns the new value.default longchangeByAndGetLong(long amount) Changes the counter by the given amount and returns the new value as a primitivelong.default Longcurrent()Get the current value of the counter.longGets the current value of the counter as a primitivelong.default LongDecrements the counter by a single unit and returns the new value.default longDecrements 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 LonggetAndChangeBy(long amount) Gets the current value of the counter, then changes the counter by the specific amount of units.default longgetAndChangeByLong(long amount) Gets the current value of the counter as a primitivelong, then changes it by the given amount.default LongGets the current value of the counter, then decrements the counter by a single unit.default longGets the current value of the counter as a primitivelong, then decrements it by a single unit.default LongGets the current value of the counter, then increments the counter by a single unit.default longGets the current value of the counter as a primitivelong, then increments it by a single unit.default LongIncrements the counter by a single unit and returns the new value.default longIncrements the counter by a single unit and returns the new value as a primitivelong.default voidSets the counter to a specific value.voidsetLong(long value) Sets the counter to a specific value, provided as a primitivelong.
-
Method Details
-
changeBy
default void changeBy(long amount) Description copied from interface:CounterChanges 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
Description copied from interface:CounterChanges the counter by the specific amount of units and returns the new value.- Specified by:
changeByAndGetin 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
-
currentLong
long currentLong()Gets the current value of the counter as a primitivelong.- Returns:
- The current value of the counter.
-
decrementAndGet
Description copied from interface:CounterDecrements the counter by a single unit and returns the new value.- Specified by:
decrementAndGetin 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
-
getAndChangeBy
Description copied from interface:CounterGets the current value of the counter, then changes the counter by the specific amount of units.- Specified by:
getAndChangeByin 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
Description copied from interface:CounterGets the current value of the counter, then decrements the counter by a single unit.- Specified by:
getAndDecrementin 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
Description copied from interface:CounterGets the current value of the counter, then increments the counter by a single unit.- Specified by:
getAndIncrementin 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
Description copied from interface:CounterIncrements the counter by a single unit and returns the new value.- Specified by:
incrementAndGetin 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
-
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.
-