Package com.github.cowwoc.tokenbucket
Class ContainerList.ConfigurationUpdater
java.lang.Object
com.github.cowwoc.tokenbucket.ContainerList.ConfigurationUpdater
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- ContainerList
Updates this ContainerList's configuration.
Thread-safety: This class is not thread-safe.
-
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.children()
Returns the children containers.clear()
Removes all children from this list.void
close()
Updates this ContainerList's configuration.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.Removes a child from 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
- Throws:
IllegalStateException
- if the updater is closed
-
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 nullIllegalStateException
- if the updater is closed
-
consumeFromAll
Indicates that the list should consume tokens from all children simultaneously.- Returns:
- this
- Throws:
IllegalStateException
- if the updater is closed
-
children
Returns the children containers.- Returns:
- the children containers
- Throws:
IllegalStateException
- if the updater is closed
-
addBucket
Adds a Bucket to this list.- Parameters:
bucketBuilder
- builds the Bucket- Returns:
- this
- Throws:
NullPointerException
- ifbucketBuilder
is nullIllegalStateException
- if the updater is closed
-
addContainerList
public ContainerList.ConfigurationUpdater addContainerList(Function<ContainerList.Builder, ContainerList> listBuilder) Adds a ContainerList to this list.- Parameters:
listBuilder
- builds the ContainerList- Returns:
- this
- Throws:
NullPointerException
- iflistBuilder
is nullIllegalStateException
- if the updater is closed
-
remove
Removes a child from this list.- Parameters:
child
- a child- Returns:
- this
- Throws:
NullPointerException
- ifchild
is nullIllegalStateException
- if the updater is closed
-
clear
Removes all children from this list.- Returns:
- this
- Throws:
IllegalStateException
- if the updater is closed
-
userData
Returns the user data associated with this list.- Returns:
- the data associated with this list
- Throws:
IllegalStateException
- if the updater is closed
-
userData
Sets user data associated with this list.- Parameters:
userData
- the data associated with this list- Returns:
- this
- Throws:
IllegalStateException
- if the updater is closed
-
close
public void close()Updates this ContainerList's configuration.- Specified by:
close
in interfaceAutoCloseable
- Throws:
IllegalArgumentException
- ifchildren
is empty
-
toString
-