public class PlantComposite extends PlantComponent implements Composite
PlantComponent
s. Duplicate
components and components with duplicate IDs are not allowed.iComponentVisitor
iComponentListener
Constructor and Description |
---|
PlantComposite()
The default, nullary constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(IPlantComponentVisitor visitor)
Sub-classes will need to override this method so that the visit operation
will work correctly.
|
void |
addComponent(Component child)
|
void |
addPlantComponent(PlantComponent component)
Adds a PlantComponent to the PlantComposite.
|
java.lang.Object |
clone()
Performs a deep copy and returns a newly instantiated Object.
|
void |
copy(PlantComposite otherObject)
Copies the contents of the other PlantComposite.
|
boolean |
equals(java.lang.Object otherObject)
Performs an equality check between two Objects.
|
Component |
getComponent(int childId)
Gets the Component with the specified ID.
|
java.util.ArrayList<Component> |
getComponents()
Gets a list of the Components stored in this PlantComposite.
|
int |
getNumberOfComponents()
Gets the number of
PlantComponent s stored in this PlantComposite. |
PlantComponent |
getPlantComponent(int childId)
Gets the PlantComponent with the specified ID if one exists.
|
java.util.List<PlantComponent> |
getPlantComponents()
Gets a list of the PlantComponents stored in this PlantComposite.
|
int |
hashCode()
Returns the hashCode of the object.
|
void |
notifyPlantCompositeListeners(java.util.List<PlantComponent> components,
boolean added)
Notifies all registered
IPlantCompositeListener s of any added or
removed PlantComponents in a separate notifier thread. |
void |
registerPlantCompositeListener(IPlantCompositeListener listener)
Registers an IPlantCompositeListener to listen to the Composite for
Component add and remove events, as well as any other specialized events
that may be too complex for a regular IUpdateableListener to interpret.
|
void |
removeComponent(int childId)
Removes the
PlantComponent with the specified ID. |
void |
unregisterPlantCompositeListener(IPlantCompositeListener listener)
Unregisters an IPlantCompositeListener from the PlantComposite.
|
accept, copy, toString
copy, getDescription, getId, getName, register, setDescription, setId, setName, unregister, update
register, unregister, update
getDescription, getId, getName, setDescription, setId, setName
public PlantComposite()
public void addComponent(Component child)
addComponent
in interface Composite
child
- The Component that should be added to the Composite.
public void addPlantComponent(PlantComponent component)
component
- The PlantComponent to add.public void removeComponent(int childId)
PlantComponent
with the specified ID.removeComponent
in interface Composite
childId
- The id of the child Component that should be removed from the Composite.
public Component getComponent(int childId)
getPlantComponent(int)
.getComponent
in interface Composite
childId
- The id of the child Component that should be retrieved from the Composite.
The child with id childId that was retrieved from the Composite. NULL if the childId was not found in the Composite.
public PlantComponent getPlantComponent(int childId)
childId
- The ID of the PlantComponent to get.public int getNumberOfComponents()
PlantComponent
s stored in this PlantComposite.getNumberOfComponents
in interface Composite
The number of child Components contained in the Composite.
public java.util.ArrayList<Component> getComponents()
getPlantComponents()
.getComponents
in interface Composite
The set of Components.
public java.util.List<PlantComponent> getPlantComponents()
public void registerPlantCompositeListener(IPlantCompositeListener listener)
listener
- The listener to register. Duplicate listeners are not
accepted.public void unregisterPlantCompositeListener(IPlantCompositeListener listener)
listener
- The listener to unregister.public void notifyPlantCompositeListeners(java.util.List<PlantComponent> components, boolean added)
IPlantCompositeListener
s of any added or
removed PlantComponents in a separate notifier thread.components
- The PlantComponents that have been added or removed from the
Composite.added
- Whether the components were added or removed.public void accept(IPlantComponentVisitor visitor)
PlantComponent
accept
in class PlantComponent
visitor
- The IPlantComponentVisitor that is visiting this
PlantComponent.public boolean equals(java.lang.Object otherObject)
PlantComponent
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 int hashCode()
PlantComponent
Returns the hashCode of the object.
hashCode
in interface Identifiable
hashCode
in class PlantComponent
The hashCode of the Object.
Identifiable.hashCode()
public java.lang.Object clone()
PlantComponent
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(PlantComposite otherObject)
otherObject
- The other object to copy the contents from.