Package Structural.Composite
Class Composite
java.lang.Object
Structural.Composite.Composite
- All Implemented Interfaces:
Component
Represents the Composite object in the Composite pattern.
A Composite can contain both Leaf and other Composite objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a child component to the Composite.getChild(int index) Retrieves a child component at the specified index.voidPerforms the operation on the Composite and its children.voidRemoves a child component from the Composite.
-
Constructor Details
-
Composite
Constructor for the Composite.- Parameters:
name- The name of the Composite.
-
-
Method Details
-
operation
public void operation()Performs the operation on the Composite and its children. -
add
Adds a child component to the Composite. -
remove
Removes a child component from the Composite. -
getChild
Retrieves a child component at the specified index.
-