- java.lang.Object
-
- io.github.bucket4j.ConsumptionProbe
-
- All Implemented Interfaces:
ComparableByContent<ConsumptionProbe>
public class ConsumptionProbe extends Object implements ComparableByContent<ConsumptionProbe>
Describes tokens consumed, tokens remaining, time required for token regeneration to occur, and the current bucket configuration after consumption.
-
-
Field Summary
Fields Modifier and Type Field Description static SerializationHandle<ConsumptionProbe>SERIALIZATION_HANDLE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConsumptionProbeconsumed(long remainingTokens, long nanosToWaitForReset)booleanequalsByContent(ConsumptionProbe other)longgetNanosToWaitForRefill()Returns zero ifisConsumed()returns true, else time in nanos which need to wait until requested amount of tokens will be refilledlonggetNanosToWaitForReset()Time in nanos which need to wait until bucket will be fully refilled to its maximumlonggetRemainingTokens()Return the tokens remaining in the bucketbooleanisConsumed()Flag describes result of consumption operation.static ConsumptionProberejected(long remainingTokens, long nanosToWaitForRefill, long nanosToWaitForReset)StringtoString()
-
-
-
Field Detail
-
SERIALIZATION_HANDLE
public static final SerializationHandle<ConsumptionProbe> SERIALIZATION_HANDLE
-
-
Method Detail
-
consumed
public static ConsumptionProbe consumed(long remainingTokens, long nanosToWaitForReset)
-
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
-
equalsByContent
public boolean equalsByContent(ConsumptionProbe other)
- Specified by:
equalsByContentin interfaceComparableByContent<ConsumptionProbe>
-
-