Class ContainerList

java.lang.Object
com.github.cowwoc.tokenbucket.internal.AbstractContainer
com.github.cowwoc.tokenbucket.ContainerList
All Implemented Interfaces:
Container

public final class ContainerList extends com.github.cowwoc.tokenbucket.internal.AbstractContainer
A container of one or more children containers.

For example, this allows to consume tokens from a list of buckets.

Thread safety: This class is thread-safe.

  • Method Details

    • builder

      public static ContainerList.Builder builder()
      Builds a bucket that contains children buckets.

      By default, the list will delegate to the first child that has sufficient number of tokens available.

      Returns:
      a new ContainerList builder
    • size

      public int size()
      Returns the number of children in this list. If this list contains more than Integer.MAX_VALUE children, returns Integer.MAX_VALUE.
      Returns:
      the number of children in this list
    • toString

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

      public ContainerList.ConfigurationUpdater updateConfiguration()
      Updates this list's configuration.

      The ContainerList will be locked until ContainerList.ConfigurationUpdater.close() is invoked.

      Returns:
      the configuration updater