code: private static boolean isValidIdentifier(String identifier) {
      if (identifier.isEmpty()) {
        return false;
      }
  
      char first = identifier.charAt(0);
      if (first != '_' && (first < 'a' || first > 'z') && (first < 'A' || first > 'Z')) {
        return false;
      }
      for (int i = 1; i < identifier.length(); i++) {
        char c = identifier.charAt(i);
        if (c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9')) {
          return false;
        }
      }
      return true;
    }
docs: Return true if the string could be used as a segment in a field path without escaping. Valid
  identifies follow the regex [a-zA-Z_][a-zA-Z0-9_]*