Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
PerfectJPattern's offers a fully componentized version of the Composite pattern in Java. Users need
only to provide the Component interface and directly use the type-safe
Composite
implementation. See example below.
If the specific context Component interface contains functions i.e. methods that should return a value
then the default Composite
implementation returns null. Users are responsible to subclass
Composite
and define how to aggregate the multiple returned values from specific Method.
In future releases the aggregation mechanism will be improved.
The Composite
implementation extends ArrayList
so it exposes all
List
features to create the compositions. ArrayList
implementation
was preferred over others for maximizing the speed of iterations.