public static boolean isValid(final String identifier) {
    final SqlBaseLexer sqlBaseLexer = new SqlBaseLexer(
        new CaseInsensitiveStream(CharStreams.fromString(identifier)));
    final CommonTokenStream tokenStream = new CommonTokenStream(sqlBaseLexer);
    final SqlBaseParser sqlBaseParser = new SqlBaseParser(tokenStream);

    // don't log or print anything in the case of error since this is expected
    // for this method
    sqlBaseLexer.removeErrorListeners();
    sqlBaseParser.removeErrorListeners();

    sqlBaseParser.identifier();

    // needs quotes if the `identifier` was not able to read the entire line
    return sqlBaseParser.getNumberOfSyntaxErrors() == 0
        && sqlBaseParser.getCurrentToken().getCharPositionInLine() == identifier.length();
  }
@Test
  public void shouldBeValid() {
    // Given:
    final String[] identifiers = new String[]{
        "FOO",   // nothing special
        "foo",   // lower-case
    };

    // Then:
    for (final String identifier : identifiers) {
      assertThat(
          "Expected " + identifier + " to be valid.",
          IdentifierUtil.isValid(identifier)
      );
    }
  }