class IdentifierUtil {

  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();
  }

  private  IdentifierUtil();

}