Class EstimationProbe

java.lang.Object
io.github.bucket4j.EstimationProbe
All Implemented Interfaces:
ComparableByContent<EstimationProbe>

public class EstimationProbe extends Object implements ComparableByContent<EstimationProbe>
Describes the estimation result.
See Also:
  • Field Details

  • Method Details

    • canBeConsumed

      public static EstimationProbe canBeConsumed(long remainingTokens)
    • canNotBeConsumed

      public static EstimationProbe canNotBeConsumed(long remainingTokens, long nanosToWaitForRefill)
    • canBeConsumed

      public boolean canBeConsumed()
      Flag describes result of consumption operation.
      Returns:
      true if requested tokens can be 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 canBeConsumed() returns true, else time in nanos which need to wait until requested amount of tokens will be refilled
      Returns:
      Zero if canBeConsumed() returns true, else time in nanos which need to wait until requested amount of tokens will be refilled
    • toString

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

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