### Question:
PatternMatch { public static PatternMatch or(PatternMatch... choice) { return new PatternMatch(PatternType.OR, (Object[]) choice); } private  PatternMatch(PatternType type, Object... args); @SuppressWarnings("unchecked") Map<String, CommonTree> match(CommonTree ct); static PatternMatch var(String name, PatternMatch p); static PatternMatch wild(); static PatternMatch kind(String k); static PatternMatch tuple(PatternMatch... tuple); PatternMatch child(PatternMatch child); PatternMatch nth(int n, PatternMatch child); static PatternMatch recursive(PatternMatch child); static PatternMatch or(PatternMatch... choice); static void replaceChildren(CommonTree dst, CommonTree src); static final Logger LOG; }### Answer:
@Test public void testOr() throws RecognitionException { CommonTree sink = FlumeBuilder .parseSink(" { batch(10) => logicalNode(\"collector\") } "); PatternMatch pdeco = tuple(kind("DECO"), var("deco", kind("SINK")), var( "child", kind("SINK"))); PatternMatch psink = tuple(kind("SINK"), var("name", wild()), var("sink", kind("STRING"))); PatternMatch pp = or(psink, pdeco); LOG.info(sink.toStringTree()); Map<String, CommonTree> m = pp.match(sink); assertNotNull(m); assertTrue(m.containsKey("deco")); dumpMatches(m); LOG.info(m); m = pp.match(m.get("child")); assertNotNull(m); assertTrue(m.containsKey("sink")); dumpMatches(m); LOG.info(m); }