Class Bucket.Builder

java.lang.Object
com.github.cowwoc.tokenbucket.Bucket.Builder
Enclosing class:
Bucket

public static final class Bucket.Builder extends Object
Builds a bucket.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • limits

      public List<Limit> limits()
      Returns the limits that the bucket must respect.
      Returns:
      the limits that the bucket must respect
    • addLimit

      public Bucket.Builder addLimit(Function<Limit.Builder,Limit> limitBuilder)
      Adds a limit that the bucket must respect.
      Parameters:
      limitBuilder - builds the Limit
      Returns:
      this
      Throws:
      NullPointerException - if any of the arguments are null
    • listeners

      public List<ContainerListener> listeners()
      Returns the event listeners associated with this bucket.
      Returns:
      this
    • addListener

      public Bucket.Builder addListener(ContainerListener listener)
      Adds an event listener to the bucket.
      Parameters:
      listener - a listener
      Returns:
      this
      Throws:
      NullPointerException - if listener is null
    • userData

      public Object userData()
      Returns the user data associated with this bucket.
      Returns:
      the data associated with this bucket
    • userData

      public Bucket.Builder userData(Object userData)
      Sets user data associated with this bucket.
      Parameters:
      userData - the data associated with this bucket
      Returns:
      this
    • build

      public Bucket build()
      Builds a new Bucket.
      Returns:
      a new Bucket
    • toString

      public String toString()
      Overrides:
      toString in class Object