code: private void ensureValidLookahead(CharType... expected) {
          if (!chars.positiveLookahead(expected)) {
              throw new UnexpectedCharacterException(
                  chars.lookahead(1),
                  chars.currentOffset(),
                  expected
              );
          }
      }
docs: Checks if the next character in the stream is valid.
  
  @param expected the expected types of the next character
  @throws UnexpectedCharacterException if the next character is not valid