Guest User

Untitled

a guest
Sep 26th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. public abstract class Base {
  2. public static class A extends Base { ... }
  3. public static class B extends Base { ... }
  4.  
  5. public static Base createA(...) { return new A(...); }
  6. public static Base createB(...) { return new B(...); }
  7.  
  8. public static interface Visitor<T> {
  9. T visit(A a);
  10. T visit(B b);
  11. }
  12.  
  13. public abstract <T> T accept(Visitor<T> visitor);
  14. }
Add Comment
Please, Sign In to add comment