CharBuffer { boolean nextIs(char c) { return hasRemaining() && cs[position] == c; } private  CharBuffer(char[] cs); @Override String toString(); public char[] cs; public int position; }
@Test public void nextIs() { CharBuffer buffer = CharBuffer.fromString("[C@H]"); assertFalse(buffer.nextIs('C')); assertFalse(buffer.nextIs('@')); assertFalse(buffer.nextIs('H')); assertFalse(buffer.nextIs(']')); assertTrue(buffer.nextIs('[')); assertThat(buffer.get(), is('[')); assertFalse(buffer.nextIs('[')); assertFalse(buffer.nextIs('@')); assertFalse(buffer.nextIs('H')); assertFalse(buffer.nextIs(']')); assertTrue(buffer.nextIs('C')); assertThat(buffer.get(), is('C')); assertFalse(buffer.nextIs('[')); assertFalse(buffer.nextIs('C')); assertFalse(buffer.nextIs('H')); assertFalse(buffer.nextIs(']')); assertTrue(buffer.nextIs('@')); assertThat(buffer.get(), is('@')); assertFalse(buffer.nextIs('[')); assertFalse(buffer.nextIs('C')); assertFalse(buffer.nextIs('@')); assertFalse(buffer.nextIs(']')); assertTrue(buffer.nextIs('H')); assertThat(buffer.get(), is('H')); assertFalse(buffer.nextIs('[')); assertFalse(buffer.nextIs('C')); assertFalse(buffer.nextIs('@')); assertFalse(buffer.nextIs('H')); assertTrue(buffer.nextIs(']')); assertThat(buffer.get(), is(']')); }