-
-
Save Riduidel/69b5fd35b023915d0e54e0a09f77b80f to your computer and use it in GitHub Desktop.
Visitor - 7 - startVisit(...) avec boolean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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