Composite, Visitor, and Iterator patterns implemented in java