Class BeveragePourBuilder
PourSequence as a list of Pourable objects, each with
an associated volume, that can be poured as an atomic operation.
A builder is bound to a pour pipeline and is single use. The builder
can be used to construct a sequence by calling the various pour
api's ending with a call to pour(). This will generate the
final sequence and pass it to the associated pipeline to be converted
to a FutureWork(). The future can then be started to perform
the physical pour. Once pour() has been called, the builder
can no longer be used and all methods will throw an exception.
The builder provides access to pours based on the currently selected
beverage. This leverages the associated BeveragePipelineService
class which has a concept of selected beverage and corresponding
endpoints. This typically allows developers to avoid introducing
custom code or endpoints to manage beverage selection, although doesn't
preclude it.
The builder also leverages named volumes to handle common use cases
such as pre-configured cup sizes. The BeverageNozzlePipeline
supports a BeveragePipelineDelegate which defines the max
volume pour as well as resolves named volumes to actual numeric values.
This allows the pipeline to route volume resolution to any user defined
process.
Virtually all methods in the builder operate on Pourable objects.
A Pourable defines the beverage to pour and can contain a volume.
In some cases the volume from the provided pourable is used, but in many
cases a new volume is computed based on inputs. In every instance, the
provided Pourable is first cloned and then updated to use the
computed volume, leaving the original pourable unchanged.
- Since:
- 1.0
- Version:
- 2023-09-09
-
Method Summary
Modifier and TypeMethodDescriptionaddFixedPour(Pourable pourable, String fixedName) Add the specifiedPourableusing the named pour volume.addFixedPour(Pourable pourable, String fixedName, double splitPercent, int delay) Add the specifiedPourableusing the named pour volume and optionally split into two separate pours at the specified percent using the specified delay.Add the specifiedPourableusing the effective volume specified in the pourable.addSelectedFixedPour(String fixedName) Add the currently selectedPourableusing the named pour volume.addSelectedFixedPour(String fixedName, double splitPercent, int delay) Add the currently selectedPourableusing the named pour volume and optionally split into two separate pours at the specified percent using the specified delay.Add the currently selectedPourableusing the max pour volume from thePourServiceDelegateas the limit.addSelectedVolumePour(double volume) Add the currently selectedPourableusing the specified volume.addVolumePour(Pourable pourable, double volume) Add the specifiedPourableusing the specified volume.com.tccc.kos.commons.util.concurrent.future.FutureWorkpour()Pour the sequence defined by the current state of the builder.
-
Method Details
-
addSelectedMaxVolumePour
Add the currently selectedPourableusing the max pour volume from thePourServiceDelegateas the limit. This is typically used for pouring triggered by a hold-to-pour button where releasing the button will cancel the pour.- Throws:
BeveragePourBuilderException- ifPourEngineDelegateisn't set
-
addSelectedVolumePour
Add the currently selectedPourableusing the specified volume.- Parameters:
volume- the volume to pour in milliliters- Throws:
BeveragePourBuilderException- if noPourableis currently selected
-
addVolumePour
Add the specifiedPourableusing the specified volume. This will clone the pourable and set the totalVolume to the specified volume and set start / stop percent as specified.The specified
Pourablewill be cloned and the volume will be set on the clone. Any volume on the incoming pourable will be ignored.- Parameters:
pourable- the pourable to pourvolume- the volume to pour in milliliters
-
addPour
Add the specifiedPourableusing the effective volume specified in the pourable. This will clone the pourable.The specified
Pourablewill be cloned and added to the sequence. The volume of the original pourable can be changed after this call without impacting the sequence.- Parameters:
pourable- the pourable to pour
-
addSelectedFixedPour
Add the currently selectedPourableusing the named pour volume.PourServiceDelegateis used to convertFixedNameto a volume.If the pourable implements
FixedPourAwarethen the pour will be split based on the information from the pourable. If not, the pour will not be split.The specified
Pourablewill be cloned and the volume will be set on the clone. Any volume on the incoming pourable will be ignored.- Parameters:
fixedName- the name to resolve to a volume usingPourServiceDelegate
-
addSelectedFixedPour
Add the currently selectedPourableusing the named pour volume and optionally split into two separate pours at the specified percent using the specified delay.PourServiceDelegateis used to convertFixedNameto a volume.If splitPercent is <=0 or >=100 then there will be a single pour for the entire volume and the delay will be ignored. For any other value of splitPercent, the pour will be split and the specified delay inserted.
- Parameters:
fixedName- the name to resolve to a volume usingPourServiceDelegatesplitPercent- where to split the pour into two pours with the delaydelay- the delay between two parts of a split pour in milliseconds
-
addFixedPour
Add the specifiedPourableusing the named pour volume.PourServiceDelegateis used to convertFixedNameto a volume.If the pourable implements
FixedPourAwarethen the pour will be split based on the information from the pourable. If not, the pour will not be split.The specified
Pourablewill be cloned and the volume will be set on the clone. Any volume on the incoming pourable will be ignored.- Parameters:
pourable- the pourable to addfixedName- the name to resolve to a volume usingPourServiceDelegate
-
addFixedPour
public BeveragePourBuilder addFixedPour(Pourable pourable, String fixedName, double splitPercent, int delay) Add the specifiedPourableusing the named pour volume and optionally split into two separate pours at the specified percent using the specified delay.PourServiceDelegateis used to convertFixedNameto a volume.If
splitPercentis <=0 or >=100 then there will be a single pour for the entire volume and the delay will be ignored. For any other value ofsplitPercentsplitPercent, the pour will be split into two parts with the delay between them.The specified
Pourablewill be cloned and the volume will be set on the clone. Any volume on the incoming pourable will be ignored.- Parameters:
pourable- the pourable to addfixedName- the name to resolve to a volume usingPourServiceDelegatesplitPercent- where to split the pour into two pours with the delaydelay- the delay between two parts of a split pour in milliseconds
-
pour
public com.tccc.kos.commons.util.concurrent.future.FutureWork pour()Pour the sequence defined by the current state of the builder.
-