Class ConsumptionProbe

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.
See Also:
  • Field Details

  • Method Details

    • 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 if isConsumed() 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

      public String toString()
      Overrides:
      toString in class Object
    • equalsByContent

      public boolean equalsByContent(ConsumptionProbe other)
      Specified by:
      equalsByContent in interface ComparableByContent<ConsumptionProbe>