Skip to content

Instantly share code, notes, and snippets.

@Riduidel
Created December 10, 2020 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Riduidel/69b5fd35b023915d0e54e0a09f77b80f to your computer and use it in GitHub Desktop.
Save Riduidel/69b5fd35b023915d0e54e0a09f77b80f to your computer and use it in GitHub Desktop.
Visitor - 7 - startVisit(...) avec boolean
class Branche implements Visitable {
// [....]
@Override public <Type> Type accept(Visitor<Type> v) {
if(v.startVisit(this)) {
for(Visitable c : children) {
c.accept(v);
}
}
return v.endVisit(this);
}
}
interface Visitor<Type> {
// [....]
boolean startVisit(Branche branche);
// [....]
}
public class Main {
// [....]
@Override public boolean startVisit(Branche branche) {
returned.append("➡🌿").append('\n').toString();
return true;
}
// [....]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment