public class Junction extends PlantComponent implements IJunction
Base class for junction-like components that connect objects, such as pipes. The class keeps track of what is an input and what is an output.
iComponentVisitor
iComponentListener
Constructor and Description |
---|
Junction()
Nullary constructor.
|
Junction(java.util.ArrayList<PlantComponent> ins,
java.util.ArrayList<PlantComponent> outs,
java.util.ArrayList<java.lang.String> conns)
Parameterized constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(IPlantComponentVisitor visitor)
Accepts PlantComponentVisitors to reveal the type of a PlantComponent.
|
void |
addInput(PlantComponent input)
Adds a PlantComponent as input to the Junction.
|
void |
addOutput(PlantComponent output)
Adds an output PlantComponent to the Junction.
|
java.lang.Object |
clone()
Performs a deep copy and returns a newly instantiated Object.
|
void |
copy(Junction otherObject)
Deep copies the contents of otherObject.
|
boolean |
equals(java.lang.Object otherObject)
Performs an equality check between two Objects.
|
java.util.ArrayList<java.lang.String> |
getConnections() |
java.util.ArrayList<PlantComponent> |
getInputs()
Gets the PlantComponents, usually Pipes or HeatExchangers, that are input
for the Junction.
|
java.util.ArrayList<PlantComponent> |
getOutputs()
Gets the PlantComponents, usually Pipes or HeatExchangers, that are
output for the Junction.
|
int |
hashCode()
Returns the hashCode of the object.
|
boolean |
isInput(PlantComponent component)
This method is used to determine if a component is connected to the
Junction as input or output.
|
void |
notifyJunctionListeners(java.util.List<PlantComponent> components,
boolean added)
Notifies all registered
IJunctionListener s of any added or
removed pipes in a separate notifier thread. |
void |
registerJunctionListener(IJunctionListener listener)
Registers an IJunctionListener to listen to the Junction for pipe add and
remove events, as well as any other specialized events that may be too
complex for a regular IUpdateableListener to interpret.
|
void |
removeInput(PlantComponent input)
Removes an input PlantComponent from the Junction.
|
void |
removeOutput(PlantComponent output)
Removes an output PlantComponent from the Junction.
|
void |
setConnections(java.util.ArrayList<java.lang.String> connections) |
void |
setInputs(java.util.ArrayList<PlantComponent> ins) |
void |
setOutputs(java.util.ArrayList<PlantComponent> outs) |
void |
unregisterJunctionListener(IJunctionListener listener)
Unregisters an IJunctionListener from the Junction.
|
accept, copy, toString
copy, getDescription, getId, getName, register, setDescription, setId, setName, unregister, update
register, unregister, update
getDescription, getId, getName, setDescription, setId, setName
public Junction()
Nullary constructor.
public Junction(java.util.ArrayList<PlantComponent> ins, java.util.ArrayList<PlantComponent> outs, java.util.ArrayList<java.lang.String> conns)
ins
- Inputs of this junction.outs
- Outputs of this junction.conns
- A list of coupled input-output pairs representing the
connections of the junction.public java.util.ArrayList<PlantComponent> getInputs()
IJunction
public void setInputs(java.util.ArrayList<PlantComponent> ins)
ins
- the inputs to setpublic java.util.ArrayList<PlantComponent> getOutputs()
IJunction
getOutputs
in interface IJunction
public void setOutputs(java.util.ArrayList<PlantComponent> outs)
outs
- the outputs to setpublic java.util.ArrayList<java.lang.String> getConnections()
public void setConnections(java.util.ArrayList<java.lang.String> connections)
connections
- the connections to setpublic boolean equals(java.lang.Object otherObject)
Performs an equality check between two Objects.
equals
in interface Identifiable
equals
in class PlantComponent
otherObject
- The other Object to compare against.
Returns true if the two objects are equal, otherwise false.
Identifiable.equals(Object otherObject)
public java.lang.Object clone()
Performs a deep copy and returns a newly instantiated Object.
clone
in interface Identifiable
clone
in class PlantComponent
The newly instantiated Object.
public void copy(Junction otherObject)
Deep copies the contents of otherObject.
otherObject
- The other object to copy the contents from.
public int hashCode()
Returns the hashCode of the object.
hashCode
in interface Identifiable
hashCode
in class PlantComponent
The hashCode of the Object.
Identifiable.hashCode()
public void accept(IPlantComponentVisitor visitor)
Accepts PlantComponentVisitors to reveal the type of a PlantComponent.
accept
in class PlantComponent
visitor
- The PlantComponent's visitor.
public void registerJunctionListener(IJunctionListener listener)
IJunction
registerJunctionListener
in interface IJunction
listener
- The listener to register. Duplicate listeners are not
accepted.public void unregisterJunctionListener(IJunctionListener listener)
IJunction
unregisterJunctionListener
in interface IJunction
listener
- The listener to unregister.public void notifyJunctionListeners(java.util.List<PlantComponent> components, boolean added)
IJunction
IJunctionListener
s of any added or
removed pipes in a separate notifier thread.notifyJunctionListeners
in interface IJunction
components
- The PlantComponents that have been added or removed from the
Junction.added
- Whether the components were added or removed.public boolean isInput(PlantComponent component)
IJunction
public void addInput(PlantComponent input)
IJunction
public void removeInput(PlantComponent input)
IJunction
removeInput
in interface IJunction
input
- The PlantComponent that should be removed from the Junction.public void addOutput(PlantComponent output)
IJunction
public void removeOutput(PlantComponent output)
IJunction
removeOutput
in interface IJunction
output
- The PlantComponent that should be removed from the Junction.