java.lang.Object
io.github.bucket4j.ConsumptionProbe
- All Implemented Interfaces:
ComparableByContent<ConsumptionProbe>
Describes tokens consumed, tokens remaining, time required for token regeneration to occur, and
the current bucket configuration after consumption.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ConsumptionProbeconsumed(long remainingTokens, long nanosToWaitForReset) booleanequalsByContent(ConsumptionProbe other) longReturns zero ifisConsumed()returns true, else time in nanos which need to wait until requested amount of tokens will be refilledlongTime in nanos which need to wait until bucket will be fully refilled to its maximumlongReturn the tokens remaining in the bucketbooleanFlag describes result of consumption operation.static ConsumptionProberejected(long remainingTokens, long nanosToWaitForRefill, long nanosToWaitForReset) toString()
-
Field Details
-
SERIALIZATION_HANDLE
-
-
Method Details
-
consumed
-
rejected
public static ConsumptionProbe rejected(long remainingTokens, long nanosToWaitForRefill, long nanosToWaitForReset) -
isConsumed
public boolean isConsumed()Flag describes result of consumption operation.- Returns:
- true if tokens was consumed
-
getRemainingTokens
public long getRemainingTokens()Return the tokens remaining in the bucket- Returns:
- the tokens remaining in the bucket
-
getNanosToWaitForRefill
public long getNanosToWaitForRefill()Returns zero ifisConsumed()returns true, else time in nanos which need to wait until requested amount of tokens will be refilled- Returns:
- Zero if
isConsumed()returns true, else time in nanos which need to wait until requested amount of tokens will be refilled
-
getNanosToWaitForReset
public long getNanosToWaitForReset()Time in nanos which need to wait until bucket will be fully refilled to its maximum- Returns:
- time in nanos which need to wait until bucket will be fully refilled to its maximum
-
toString
-
equalsByContent
- Specified by:
equalsByContentin interfaceComparableByContent<ConsumptionProbe>
-