Composite
Usage
- A tree structure of simple and composite objects
- Compose objects into tree structures to represent part-whole hierarchies
- Let clients treat individual objects and compositions of objects uniformly
Participants
Component
Leaf
- Declares the interface for objects in the composition.
- implements default behavior for the interface common to all classes, as appropriate.
- Declares an interface for accessing and managing its child components.
- (optional) defines an interface for accessing a component's parent in the recursive structure, and implements it if that's appropriate.
Composite
- Represents leaf objects in the composition.
- A leaf has no children.
- Defines behavior for primitive objects in the composition.
Client
- Defines behavior for components having children.
- Stores child components.
- Implements child-related operations in the Component interface.
- Manipulates objects in the composition through the Component interface.
