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>
Enclosing class:
Conveyor<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 Details

    • polyline

      public Conveyor.PolicyBuilder<T> polyline(Polyline polyline)
      Description copied from interface: Conveyor.PolylineBuilder
      Sets the polyline of a new Conveyor
      Specified by:
      polyline in interface Conveyor.PolylineBuilder<T>
      Parameters:
      polyline - polyline
      Returns:
      a Conveyor.PolicyBuilder to set an inflow shortage policy
    • policy

      Description copied from interface: Conveyor.PolicyBuilder
      Sets the inflow shortage policy for a new Conveyor instance.
      Specified by:
      policy in interface Conveyor.PolicyBuilder<T>
      Parameters:
      policy - inflow shortage policy
      Returns:
      a Conveyor.MaxSpeedBuilder to set the max speed of a Conveyor
    • maxSpeed

      public Conveyor.Builder<T> maxSpeed(double maxSpeed)
      Description copied from interface: Conveyor.MaxSpeedBuilder
      Sets the max speed of a Conveyor instance.
      Specified by:
      maxSpeed in interface Conveyor.MaxSpeedBuilder<T>
      Parameters:
      maxSpeed - max speed of a Conveyor
      Returns:
      a Conveyor.PerformanceBuilder to set the performance of a Conveyor
    • performance

      public Conveyor.Builder<T> performance(double performance)
      Description copied from interface: Conveyor.PerformanceBuilder
      Sets the performance (max internal flow rate) of a Conveyor instance.
      Specified by:
      performance in interface Conveyor.PerformanceBuilder<T>
      Parameters:
      performance - performance of a Conveyor
      Returns:
      a Conveyor.Builder object to set optional parameters and create a Conveyor instance
    • logicalLength

      public Conveyor.Builder<T> logicalLength(double 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.Builder object
    • name

      public Conveyor.Builder<T> name(String 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 of Conveyor.class.getName() method call.
      Parameters:
      name - name of a Conveyor
      Returns:
      the same Conveyor.Builder object
    • initialContents

      public Conveyor.Builder<T> initialContents(List<MaterialFragmentDescriptor<T>> initialStock)
      Set the contents of this Conveyor with the initialStock. Each element of the initialStock list is a MaterialFragmentDescriptor
      Parameters:
      initialStock - contents of this Conveyor
      Returns:
      the same Conveyor.Builder object
    • inputFlowWithRelativeOffset

      public Conveyor.Builder<T> inputFlowWithRelativeOffset(FlowElement<T> sourceFlowElement, double relativeOffset)
      Connects the sourceFlowElement (as a source of material) to this Conveyor.

      The 'connection point', i.e. the exact location along the Conveyor where the material coming from the sourceFlowElement will be accepted by the Conveyor is set by relativeOffset (a number between 0 and 1).

      Parameters:
      sourceFlowElement - flow element that acts as a source of material
      relativeOffset - 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 the sourceFlowElement is null
      IllegalArgumentException - if relativeOffset is not in the half-open interval [0..1)
      IllegalArgumentException - if the sourceFlowElement belongs to a different FlowEnvironment than this flow element
    • inputFlowWithRelativeOffset

      public Conveyor.Builder<T> inputFlowWithRelativeOffset(List<Pair<FlowElement<T>,Double>> sourceFlowElementsByRelativeOffset)
      Connects the sourceFlowElement (as a source of material) to this Conveyor.

      The 'connection point', i.e. the exact location along the Conveyor where the material coming from the sourceFlowElement will be accepted by the Conveyor is set by relativeOffset (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 the sourceFlowElementsByRelativeOffset is null
      NullPointerException - if the sourceFlowElement is null
      IllegalArgumentException - if relativeOffset is not in the half-open interval [0..1)
      IllegalArgumentException - if the sourceFlowElement belongs to a different FlowEnvironment than this flow element
    • outputFlowElement

      public Conveyor.Builder<T> outputFlowElement(FlowElement<T> dest)
      Connects the output of this Conveyor to the input of the dest flow element.
      Parameters:
      dest - flow element to connect to
      Throws:
      NullPointerException - if the dest flow element is null
      IllegalArgumentException - if the dest flow element belongs to a different FlowEnvironment than this flow element
    • build

      public Conveyor<T> build()
      Creates a new Conveyor instance.
      Returns:
      new Conveyor instance