I have some question about the Composite pattern. I have implemented a model like these:Element is an abstract class, RegexElement is the primitive, a sub class of Element and RegexBlock, the real Composite class, that has like instance variable a List of Element.1) I would like to access to all the leafs of this structure, a sort of passing from a List of Element to a List of RegexElement. How I can do it? Create a sort of wrapper class with a List of Element as instance variable or try other way, maybe implementing a Visitor pattern?2) I saw on the web a different implementation of the Composite pattern, and most of them don't use an abstract class for my Element class, but an Interface, and an abstract class for my RegexBlock class. At the end my implementation of the pattern follows the description of the pattern:The composite pattern describes that a group of objects is to be treated in the same way as a single instance of an object.Isn't correct?Thanks in advice.
Access to the leafs of Composite pattern Java
design patterns;modeling