Class FlowElement<T>
- Type Parameters:
T- type (class or interface) whose instances represent materials
A flow element can accept, store, or export some material or mix of materials.
Material is moved between flow elements through FlowConnections.
Flow connections define the direction of material flow among flow elements.
- Author:
- Alexander Morozov
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddInflowElementConnectedHandler(Consumer<FlowConnection<T>> handler) Adds an action that will be executed every time when a new inflow element is connected.voidAdds an action that will be executed every time when a new inflow element is disconnected.voidaddOutflowElementConnectedHandler(Consumer<FlowConnection<T>> handler) Adds an action that will be executed every time when a new outflow element is connected.voidAdds an action that will be executed every time when a new outflow element is disconnected.connectToElement(FlowElement<T> dest) Connects the output of this flow element to the input of thedestflow element.disconnectFrom(FlowElement<T> destElement) Disconnects the current flow element from thedestElementflow element, if a connection from this flow element to thedestElementflow element exists.abstract doubleReturns the total quantity of all materials inside this flow element.abstract doublegetContentsAmount(T material) Returns the current quantity of the specifiedmaterialinside this flow element.abstract Accumulator<T> Returns all materials contained inside this flow element as an instance ofAccumulator.final FlowEnvironment<T> Returns theFlowEnvironmentwhich this flow element belongs to.Returns an unmodifiable list ofFlowConnectioninstances that represent incoming connections of this flow element.abstract doubleReturns the current flow rate of all materials at the input of thisflow element.abstract Accumulator<T> Returns anAccumulatorinstance that describes the flow rate at the input of this flow element.final StringgetName()Returns the name of this flow element.Returns the unmodifiable list ofFlowConnectioninstances that represent outgoing connections of this flow element.abstract doubleReturns the current flow rate at the output of this flow element.abstract Accumulator<T> Returns anAccumulatorinstance that describes the flow rate at the output of this flow element.abstract Accumulator<T> getOutflowRateProportions(FlowConnection<T> outflowConnection) Returns anAccumulatorinstance that contains flow rate proportions of materials exported through theoutflowConnectionoutflow connection.abstract doubleReturns the total amount of all materials that have entered this flow element.abstract doublegetTotalInflowAmount(T material) Returns the total amount of the specifiedmaterialthat has entered this flow element.abstract Accumulator<T> Returns anAccumulatorinstance that contains the total quantity of each material that has entered this flow element.abstract doubleReturns the total quantity of materials that have left this flow element.abstract doublegetTotalOutflowAmount(T material) Returns the total quantity of the specifiedmaterialthat has left this flow element.abstract Accumulator<T> Returns anAccumulatorinstance that holds the total amounts of each material that has left this flow element.final booleanIndicates that at least one incoming flow connection exists.final booleanisConnectedWith(FlowElement<T> element) Checks whether a connection exists between this flow element and theelementflow element.final booleanIndicates that at least one outgoing flow connection exists.voidRemoves the previously added inflow element connect handler.voidRemoves the previously added inflow element disconnect handler.voidRemoves the previously added outflow element connect handler.voidRemoves the previously added outflow element disconnect handler.toString()
-
Method Details
-
getInflowConnections
Returns an unmodifiable list ofFlowConnectioninstances that represent incoming connections of this flow element.- Returns:
- unmodifiable list of inflow connections
- See Also:
-
getOutflowConnections
Returns the unmodifiable list ofFlowConnectioninstances that represent outgoing connections of this flow element.- Returns:
- unmodifiable list of outflow connections
- See Also:
-
connectToElement
Connects the output of this flow element to the input of thedestflow element.- Parameters:
dest- flow element to connect to- Returns:
- a new
FlowConnection, with this flow element as its source anddestflow element as its destination - Throws:
NullPointerException- if thedestflow element isnullIllegalArgumentException- if thedestflow element belongs to a differentFlowEnvironmentthan this flow element- See Also:
-
disconnectFrom
Disconnects the current flow element from thedestElementflow element, if a connection from this flow element to thedestElementflow element exists.- Parameters:
destElement- flow element to be disconnected from- Returns:
- a
FlowConnectionbetween this flow element and thedestElementthat was removed during the method call;nullif no connection existed - Throws:
IllegalArgumentException- ifdestElementbelongs to a differentFlowEnvironmentthan this flow element
-
getTotalInflowAmount
public abstract double getTotalInflowAmount()Returns the total amount of all materials that have entered this flow element.- Returns:
- total amount of all arrived materials
-
getTotalInflowAmount
Returns the total amount of the specifiedmaterialthat has entered this flow element.- Parameters:
material- material- Returns:
- total amount of the specified
materialthat has arrived to this flow element - See Also:
-
getTotalInflowDescriptor
Returns anAccumulatorinstance that contains the total quantity of each material that has entered this flow element.The values of each element in the returned
Accumulatormatch the quantities of the respective materials that have entered the flow element. The sum of values in the Accumulator is equal to the value returned by thegetTotalInflowAmount()method.- Returns:
Accumulatorcontaining total amounts of materials that have entered this flow element- See Also:
-
getTotalOutflowAmount
public abstract double getTotalOutflowAmount()Returns the total quantity of materials that have left this flow element.- Returns:
- total quantity of exported materials
- See Also:
-
getTotalOutflowAmount
Returns the total quantity of the specifiedmaterialthat has left this flow element.- Parameters:
material- material- Returns:
- total quantity of the specified material that has left this flow element
- See Also:
-
getTotalOutflowDescriptor
Returns anAccumulatorinstance that holds the total amounts of each material that has left this flow element.The values of each element in the returned
Accumulatormatch the quantities of the respective materials that have left the flow element. The sum of values in the Accumulator is equal to the value returned by thegetTotalOutflowAmount()method.- Returns:
Accumulatorcontaining total amounts of materials that have left this flow element- See Also:
-
getName
Returns the name of this flow element.- Returns:
- name of this flow element
-
isConnectedWith
Checks whether a connection exists between this flow element and theelementflow element. The direction of the connection is arbitrary.- Parameters:
element- another flow element- Returns:
trueif aFlowConnectionexists that connects the current flow element and theelement,falseotherwise- See Also:
-
inflowConnectionExists
public final boolean inflowConnectionExists()Indicates that at least one incoming flow connection exists.- Returns:
trueif that at least one incoming flow connection exists,falseotherwise
-
outflowConnectionExists
public final boolean outflowConnectionExists()Indicates that at least one outgoing flow connection exists.- Returns:
trueif that at least one outgoing flow connection exists,falseotherwise
-
getFlowEnvironment
Returns theFlowEnvironmentwhich this flow element belongs to.- Returns:
FlowEnvironmentwhich this flow element belongs to
-
getContentsAmount
public abstract double getContentsAmount()Returns the total quantity of all materials inside this flow element.- Returns:
- current sum of all material quantities inside this flow element
- See Also:
-
getContentsAmount
Returns the current quantity of the specifiedmaterialinside this flow element.- Parameters:
material- material- Returns:
- current quantity of the specified material inside this flow element
- See Also:
-
getContentsDescriptor
Returns all materials contained inside this flow element as an instance ofAccumulator.Each element of the Accumulator matches the amount of the corresponding material inside this flow element. The sum of amounts of materials in the Accumulator instance is equal to the value returned by the
getContentsAmount()method.- Returns:
Accumulatorcontaining all materials inside the flow element- See Also:
-
getInflowRate
public abstract double getInflowRate()Returns the current flow rate of all materials at the input of thisflow element.- Returns:
- current flow rate of all materials at this
flow element's input - See Also:
-
getInflowRateDescriptor
Returns anAccumulatorinstance that describes the flow rate at the input of this flow element.The returned
Accumulatorinstance contains the respective rates of all materials currently entering the flow element. The sum of values in the Accumulator is equal to 1.- Returns:
- descriptor of the current inflow rate
- See Also:
-
getOutflowRate
public abstract double getOutflowRate()Returns the current flow rate at the output of this flow element.- Returns:
- current flow rate at the output of this flow element
- See Also:
-
getOutflowRateDescriptor
Returns anAccumulatorinstance that describes the flow rate at the output of this flow element.The returned
Accumulatorinstance contains the respective rates of all materials currently leaving the flow element. The sum of values in the Accumulator is equal to 1.- Returns:
- descriptor of the current outflow rate
- See Also:
-
getOutflowRateProportions
Returns anAccumulatorinstance that contains flow rate proportions of materials exported through theoutflowConnectionoutflow connection.Each element of the returned
Accumulatorcorresponds to a material in the current material flow ofoutflowConnection. The value of each element in the Accumulator is the ratio of the rate of that material's partial flow to the overall flow rate ofoutflowConnection. The sum of values in the Accumulator is equal to 1.- Parameters:
outflowConnection- an outflow connection- Returns:
- material proportions in the outflow connection
- Throws:
IllegalArgumentException- if theoutflowConnectionis not related to this flow element
-
addInflowElementConnectedHandler
Adds an action that will be executed every time when a new inflow element is connected.- Parameters:
handler- action that will be executed every time when a new inflow element is connected- See Also:
-
removeInflowElementConnectedHandler
Removes the previously added inflow element connect handler.- Parameters:
handler- previously added inflow element connect handler- See Also:
-
addOutflowElementConnectedHandler
Adds an action that will be executed every time when a new outflow element is connected.- Parameters:
handler- action that will be executed every time when a new outflow element is connected- See Also:
-
removeOutflowElementConnectedHandler
Removes the previously added outflow element connect handler.- Parameters:
handler- previously added outflow element connect handler- See Also:
-
addInflowElementDisconnectedHandler
Adds an action that will be executed every time when a new inflow element is disconnected.- Parameters:
handler- action that will be executed every time when a new inflow element is disconnected- See Also:
-
removeInflowElementDisconnectedHandler
Removes the previously added inflow element disconnect handler.- Parameters:
handler- previously added inflow element disconnect handler- See Also:
-
addOutflowElementDisconnectedHandler
Adds an action that will be executed every time when a new outflow element is disconnected.- Parameters:
handler- action that will be executed every time when a new outflow element is disconnected- See Also:
-
removeOutflowElementDisconnectedHandler
Removes the previously added outflow element disconnect handler.- Parameters:
handler- previously added outflow element disconnect handler- See Also:
-
toString
-