PatternMatch { public static PatternMatch tuple(PatternMatch... tuple) { return new PatternMatch(PatternType.TUPLE, (Object[]) tuple); } 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; }
@Test public void testTuple() throws RecognitionException { CommonTree sink = FlumeBuilder .parseSink(" { batch(10) => logicalNode(\"collector\") } "); PatternMatch pp = recursive(tuple(kind("SINK"), kind("logicalNode"), var( "LogicalNodeName", kind("STRING")))); Map<String, CommonTree> m = pp.match(sink); assertNotNull(m); dumpMatches(m); LOG.info(m); }