Class Conveyor.Builder<T>
java.lang.Object
com.amalgamasimulation.discreterate.Conveyor.Builder<T>
- All Implemented Interfaces:
Conveyor.MaxSpeedBuilder<T>,Conveyor.PerformanceBuilder<T>,Conveyor.PolicyBuilder<T>,Conveyor.PolylineBuilder<T>
public static class Conveyor.Builder<T>
extends Object
implements Conveyor.PolylineBuilder<T>, Conveyor.PolicyBuilder<T>, Conveyor.MaxSpeedBuilder<T>, Conveyor.PerformanceBuilder<T>
Helper class to create a
Conveyor instance.
Use Conveyor.builder(FlowEnvironment) method as the starting point.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates a new Conveyor instance.initialContents(List<MaterialFragmentDescriptor<T>> initialStock) Set the contents of this Conveyor with theinitialStock.inputFlowWithRelativeOffset(FlowElement<T> sourceFlowElement, double relativeOffset) Connects thesourceFlowElement(as a source of material) to thisConveyor.inputFlowWithRelativeOffset(List<Pair<FlowElement<T>, Double>> sourceFlowElementsByRelativeOffset) Connects thesourceFlowElement(as a source of material) to thisConveyor.logicalLength(double logicalLength) Sets the logical length of a Conveyor.maxSpeed(double maxSpeed) Sets the max speed of a Conveyor instance.Sets the name of a Conveyor.outputFlowElement(FlowElement<T> dest) Connects the output of this Conveyor to the input of thedestflow element.performance(double performance) Sets the performance (max internal flow rate) of a Conveyor instance.Sets the inflow shortage policy for a new Conveyor instance.Sets the polyline of a new Conveyor
-
Method Details
-
polyline
Description copied from interface:Conveyor.PolylineBuilderSets the polyline of a new Conveyor- Specified by:
polylinein interfaceConveyor.PolylineBuilder<T>- Parameters:
polyline- polyline- Returns:
- a
Conveyor.PolicyBuilderto set an inflow shortage policy
-
policy
Description copied from interface:Conveyor.PolicyBuilderSets the inflow shortage policy for a new Conveyor instance.- Specified by:
policyin interfaceConveyor.PolicyBuilder<T>- Parameters:
policy- inflow shortage policy- Returns:
- a
Conveyor.MaxSpeedBuilderto set the max speed of a Conveyor
-
maxSpeed
Description copied from interface:Conveyor.MaxSpeedBuilderSets the max speed of a Conveyor instance.- Specified by:
maxSpeedin interfaceConveyor.MaxSpeedBuilder<T>- Parameters:
maxSpeed- max speed of a Conveyor- Returns:
- a
Conveyor.PerformanceBuilderto set the performance of a Conveyor
-
performance
Description copied from interface:Conveyor.PerformanceBuilderSets the performance (max internal flow rate) of a Conveyor instance.- Specified by:
performancein interfaceConveyor.PerformanceBuilder<T>- Parameters:
performance- performance of a Conveyor- Returns:
- a
Conveyor.Builderobject to set optional parameters and create a Conveyor instance
-
logicalLength
Sets the logical length of a Conveyor. This is an optional parameter. If not set, the logical length of a Conveyor is calculated by the Conveyor's polyline.- Parameters:
logicalLength- logical length of a Conveyor- Returns:
- the same
Conveyor.Builderobject
-
name
Sets the name of a Conveyor. This is an optional parameter. If not set, the name of a new Conveyor is equal to the result ofConveyor.class.getName()method call.- Parameters:
name- name of a Conveyor- Returns:
- the same
Conveyor.Builderobject
-
initialContents
Set the contents of this Conveyor with theinitialStock. Each element of theinitialStocklist is aMaterialFragmentDescriptor- Parameters:
initialStock- contents of this Conveyor- Returns:
- the same
Conveyor.Builderobject
-
inputFlowWithRelativeOffset
public Conveyor.Builder<T> inputFlowWithRelativeOffset(FlowElement<T> sourceFlowElement, double relativeOffset) Connects thesourceFlowElement(as a source of material) to thisConveyor.The 'connection point', i.e. the exact location along the Conveyor where the material coming from the
sourceFlowElementwill be accepted by the Conveyor is set byrelativeOffset(a number between 0 and 1).- Parameters:
sourceFlowElement- flow element that acts as a source of materialrelativeOffset- a number in the half-open interval [0..1) (0 - allowed, 1 - not allowed) that defines the point of incoming connection, where 0 means 'the beginning of the Conveyor'- Throws:
NullPointerException- if thesourceFlowElementisnullIllegalArgumentException- ifrelativeOffsetis not in the half-open interval [0..1)IllegalArgumentException- if thesourceFlowElementbelongs to a differentFlowEnvironmentthan this flow element
-
inputFlowWithRelativeOffset
public Conveyor.Builder<T> inputFlowWithRelativeOffset(List<Pair<FlowElement<T>, Double>> sourceFlowElementsByRelativeOffset) Connects thesourceFlowElement(as a source of material) to thisConveyor.The 'connection point', i.e. the exact location along the Conveyor where the material coming from the
sourceFlowElementwill be accepted by the Conveyor is set byrelativeOffset(a number between 0 and 1).- Parameters:
sourceFlowElementsByRelativeOffset- collection of pairs where the first element is flow element that acts as a source of material and the second element is a number in the half-open interval [0..1) (0 - allowed, 1 - not allowed) that defines the point of incoming connection, where 0 means 'the beginning of the Conveyor'- Throws:
NullPointerException- if thesourceFlowElementsByRelativeOffsetisnullNullPointerException- if thesourceFlowElementisnullIllegalArgumentException- ifrelativeOffsetis not in the half-open interval [0..1)IllegalArgumentException- if thesourceFlowElementbelongs to a differentFlowEnvironmentthan this flow element
-
outputFlowElement
Connects the output of this Conveyor to the input of thedestflow element.- Parameters:
dest- flow element to connect to- Throws:
NullPointerException- if thedestflow element isnullIllegalArgumentException- if thedestflow element belongs to a differentFlowEnvironmentthan this flow element
-
build
Creates a new Conveyor instance.- Returns:
- new Conveyor instance
-