Package Structural.Composite
Interface Component
public interface Component
The Component interface declares common operations for both leaf and composite objects.
-
Method Details
-
operation
void operation()Performs an operation on the component. -
add
Adds a child component. This method is optional and can throw UnsupportedOperationException for leaf nodes.- Parameters:
component- The child component to add.
-
remove
Removes a child component. This method is optional and can throw UnsupportedOperationException for leaf nodes.- Parameters:
component- The child component to remove.
-
getChild
Retrieves a child component at the specified index. This method is optional and can throw UnsupportedOperationException for leaf nodes.- Parameters:
index- The index of the child component to retrieve.- Returns:
- The child component.
-