ReaderStream { public Optional<Object> match() throws IOException { return childMatch.match(); } ReaderStream(PushbackReader reader);  ReaderStream(Reader reader, int bufSize);  ReaderStream(PushbackReader reader, int bufSize, ParentMatch parentMatch);  ReaderStream(Reader reader, int bufSize, ParentMatch parentMatch); static ReaderStream<NoneReadMatch> of(); static ReaderStream<NoneReadMatch> of(PushbackReader reader); static ReaderStream<NoneReadMatch> of(Reader reader); static ReaderStream<NoneReadMatch> of(Reader reader, int pushBackCount); ReaderStream<ParentMatch> use(PushbackReader reader); ReaderStream<ParentMatch> use(Reader reader); ReaderStream<ParentMatch> use(Reader reader, int bufSize); ReaderStream<ParentMatch> use(PushbackReader reader, int bufSize, ParentMatch parentMatch); ReaderStream<ParentMatch> use(Reader reader, int bufSize, ParentMatch parentMatch); SingleCharMatch<ReaderStream<ParentMatch>> next(); MultipleCharMatch<ReaderStream<ParentMatch>> next(int count); ParentMatch back(); Optional<Object> match(); int read(); int read(CharBuffer charBuffer); ReaderStream read(int maxCount, Consumer<CharBuffer> consumer); @Override String toString();  }
@Test public void testMatch() throws IOException { String data = "C=c;B=&&B1=b1;A=&&A1=a1;A2=a2;A3=a3&&&&"; PushbackReader reader = new PushbackReader(new StringReader(data)); CharBuffer buffer = CharBuffer.allocate(10); int len = ReaderStream.of(reader) .next() .when(c -> c =='=') .then() .next(2) .when(c -> Arrays.equals(c,new char[]{'&','&'})) .then(() -> { System.out.print("is '=&&'"); }) .back() .back() .then(() -> { System.out.print("is '='"); }) .done() .read(buffer); assertEquals(len,1); }