Class ReversibleConveyor.Builder<T>
java.lang.Object
com.amalgamasimulation.discreterate.ReversibleConveyor.Builder<T>
- All Implemented Interfaces:
ReversibleConveyor.MaxSpeedBuilder<T>,ReversibleConveyor.PerformanceBuilder<T>,ReversibleConveyor.PolicyBuilder<T>,ReversibleConveyor.PolylineBuilder<T>
- Enclosing class:
ReversibleConveyor<T>
public static class ReversibleConveyor.Builder<T>
extends Object
implements ReversibleConveyor.PolylineBuilder<T>, ReversibleConveyor.PolicyBuilder<T>, ReversibleConveyor.MaxSpeedBuilder<T>, ReversibleConveyor.PerformanceBuilder<T>
Helper class to create a
ReversibleConveyor instance.
Use ReversibleConveyor.builder(FlowEnvironment) method as the starting point.-
Method Summary
Modifier and TypeMethodDescriptionConnects the backward output (the beginning of the conveyor in the forward direction) of this Conveyor to the input of thedestflow element.build()Creates a new ReversibleConveyor instance.forwardOutputFlowElement(FlowElement<T> dest) Connects the forward output of this Conveyor to the input of thedestflow element.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 thisReversibleConveyor.inputFlowWithRelativeOffset(List<Pair<FlowElement<T>, Double>> sourceFlowElementsByRelativeOffset) Connects thesourceFlowElement(as a source of material) to thisReversibleConveyor.logicalLength(double logicalLength) Sets the logical length of a Conveyor.maxSpeed(double maxSpeed) Sets the max speed of a ReversibleConveyor instance.Sets the name of a Conveyor.performance(double performance) Sets the performance (max internal flow rate) of a ReversibleConveyor instance.Sets the inflow shortage policy for a new ReversibleConveyor instance.Sets the polyline of a new ReversibleConveyor
-
Method Details
-
polyline
Description copied from interface:ReversibleConveyor.PolylineBuilderSets the polyline of a new ReversibleConveyor- Specified by:
polylinein interfaceReversibleConveyor.PolylineBuilder<T>- Parameters:
polyline- polyline- Returns:
- a
ReversibleConveyor.PolicyBuilderto set an inflow shortage policy
-
policy
public ReversibleConveyor.MaxSpeedBuilder<T> policy(Conveyor.DownstreamInflowRateShortagePolicy policy) Description copied from interface:ReversibleConveyor.PolicyBuilderSets the inflow shortage policy for a new ReversibleConveyor instance.- Specified by:
policyin interfaceReversibleConveyor.PolicyBuilder<T>- Parameters:
policy- inflow shortage policy- Returns:
- a
ReversibleConveyor.MaxSpeedBuilderto set the max speed of a Conveyor
-
maxSpeed
Description copied from interface:ReversibleConveyor.MaxSpeedBuilderSets the max speed of a ReversibleConveyor instance.- Specified by:
maxSpeedin interfaceReversibleConveyor.MaxSpeedBuilder<T>- Parameters:
maxSpeed- max speed of a Conveyor- Returns:
- a
ReversibleConveyor.PerformanceBuilderto set the performance of a Conveyor
-
performance
Description copied from interface:ReversibleConveyor.PerformanceBuilderSets the performance (max internal flow rate) of a ReversibleConveyor instance.- Specified by:
performancein interfaceReversibleConveyor.PerformanceBuilder<T>- Parameters:
performance- performance of a Conveyor- Returns:
- a
ReversibleConveyor.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
ReversibleConveyor.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
ReversibleConveyor.Builderobject
-
initialContents
public ReversibleConveyor.Builder<T> initialContents(List<MaterialFragmentDescriptor<T>> initialStock) Set the contents of this Conveyor with theinitialStock. Each element of theinitialStocklist is aMaterialFragmentDescriptor- Parameters:
initialStock- contents of this Conveyor- Returns:
- the same
ReversibleConveyor.Builderobject
-
inputFlowWithRelativeOffset
public ReversibleConveyor.Builder<T> inputFlowWithRelativeOffset(FlowElement<T> sourceFlowElement, double relativeOffset) Connects thesourceFlowElement(as a source of material) to thisReversibleConveyor.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 open interval (0..1) (0 - not 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 open interval (0..1)IllegalArgumentException- if thesourceFlowElementbelongs to a differentFlowEnvironmentthan this flow element
-
inputFlowWithRelativeOffset
public ReversibleConveyor.Builder<T> inputFlowWithRelativeOffset(List<Pair<FlowElement<T>, Double>> sourceFlowElementsByRelativeOffset) Connects thesourceFlowElement(as a source of material) to thisReversibleConveyor.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 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 open interval (0..1)IllegalArgumentException- if thesourceFlowElementbelongs to a differentFlowEnvironmentthan this flow element
-
forwardOutputFlowElement
Connects the forward 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
-
backwardOutputFlowElement
Connects the backward output (the beginning of the conveyor in the forward direction) of this Conveyor to the input of thedestflow element. This output is used in backward direction.- 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 ReversibleConveyor instance.- Returns:
- new ReversibleConveyor instance
-