Skip to content

Commit

Permalink
Add visitor pattern for transition factories.
Browse files Browse the repository at this point in the history
Part of #22248.

PiperOrigin-RevId: 632193752
Change-Id: Ic41afbc4ec508ad08615a8861278d5593bb73849
  • Loading branch information
katre authored and Copybara-Service committed May 9, 2024
1 parent f313376 commit c7c33b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,10 @@ public boolean isTool() {
public boolean isSplit() {
return transitionFactory1().isSplit() || transitionFactory2().isSplit();
}

@Override
public void visit(Visitor<T> visitor) {
this.transitionFactory1().visit(visitor);
this.transitionFactory2().visit(visitor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,14 @@ default boolean isTool() {
default boolean isSplit() {
return false;
}

/** Visit this trnsition factory with the given visitor. */
default void visit(Visitor<T> visitor) {
visitor.visit(this);
}

/** Interface used to progressively visit transitions. */
interface Visitor<T extends TransitionFactory.Data> {
void visit(TransitionFactory<T> factory);
}
}

0 comments on commit c7c33b1

Please sign in to comment.