Package com.github.cowwoc.tokenbucket
Class ContainerList.Builder
java.lang.Object
com.github.cowwoc.tokenbucket.ContainerList.Builder
- Enclosing class:
- ContainerList
Builds a ContainerList.
-
Method Summary
Modifier and TypeMethodDescriptionaddBucket
(Function<Bucket.Builder, Bucket> bucketBuilder) Adds a Bucket to this list.addContainerList
(Function<ContainerList.Builder, ContainerList> listBuilder) Adds a ContainerList to this list.addListener
(ContainerListener listener) Adds an event listener to the list.build()
Builds a new ContainerList.children()
Returns the children containers.Indicates that the list should consume tokens from all children simultaneously.consumeFromOne
(SelectionPolicy selectionPolicy) Indicates that the list should delegate to the first child that has sufficient number of tokens available.Returns the consumption policy indicating how to consume tokens from children containers.Returns the event listeners associated with this list.toString()
userData()
Returns the user data associated with this list.Sets user data associated with this list.
-
Method Details
-
consumptionPolicy
Returns the consumption policy indicating how to consume tokens from children containers.- Returns:
- the consumption policy
-
consumeFromOne
Indicates that the list should delegate to the first child that has sufficient number of tokens available.- Parameters:
selectionPolicy
- determines the order in which buckets are evaluated- Returns:
- this
- Throws:
NullPointerException
- ifselectionPolicy
is null
-
consumeFromAll
Indicates that the list should consume tokens from all children simultaneously.- Returns:
- this
-
listeners
Returns the event listeners associated with this list.- Returns:
- this
-
addListener
Adds an event listener to the list.- Parameters:
listener
- a listener- Returns:
- this
- Throws:
NullPointerException
- iflistener
is null
-
children
Returns the children containers.- Returns:
- the children containers
-
addBucket
Adds a Bucket to this list.- Parameters:
bucketBuilder
- builds the Bucket- Returns:
- this
- Throws:
NullPointerException
- ifbucketBuilder
is null
-
addContainerList
public ContainerList.Builder addContainerList(Function<ContainerList.Builder, ContainerList> listBuilder) Adds a ContainerList to this list.- Parameters:
listBuilder
- builds the ContainerList- Returns:
- this
- Throws:
NullPointerException
- iflistBuilder
is null
-
userData
Returns the user data associated with this list.- Returns:
- the data associated with this list
-
userData
Sets user data associated with this list.- Parameters:
userData
- the data associated with this list- Returns:
- this
-
build
Builds a new ContainerList.- Returns:
- a new ContainerList
- Throws:
IllegalArgumentException
- ifbuckets
is empty
-
toString
-