Skip to content

Instantly share code, notes, and snippets.

@mudiadamz
Created May 3, 2020 09:48
Show Gist options
  • Save mudiadamz/215fb7307b242c225c5092985afadf54 to your computer and use it in GitHub Desktop.
Save mudiadamz/215fb7307b242c225c5092985afadf54 to your computer and use it in GitHub Desktop.
package visitorpatern;
public class VisitorPattern {
public static void main(final String[] args) {
//visit all children nodes
StaticData.PERSON.acceptChildren(new PersonRecursiveVisitor() {
@Override
public void visit(Person person) {
//visit and print the person name
System.out.println(person.getName());
super.visit(person);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment