code: static String validateObjectName(String objectName, boolean allowEmptyObjectName) {
      logger.atFine().log("validateObjectName('%s', %s)", objectName, allowEmptyObjectName);
  
      if (isNullOrEmpty(objectName) || objectName.equals(PATH_DELIMITER)) {
        if (allowEmptyObjectName) {
          objectName = "";
        } else {
          throw new IllegalArgumentException(
              "Google Cloud Storage path must include non-empty object name.");
        }
      }
  
      // We want objectName to look like a traditional file system path,
      // therefore, disallow objectName with consecutive '/' chars.
      for (int i = 0; i < (objectName.length() - 1); i++) {
        if (objectName.charAt(i) == '/' && objectName.charAt(i + 1) == '/') {
          throw new IllegalArgumentException(
              String.format(
                  "Google Cloud Storage path must not have consecutive '/' characters, got '%s'",
                  objectName));
        }
      }
  
      // Remove leading '/' if it exists.
      if (objectName.startsWith(PATH_DELIMITER)) {
        objectName = objectName.substring(1);
      }
  
      logger.atFine().log("validateObjectName -> '%s'", objectName);
      return objectName;
    }
docs: Validate the given object name to make sure that it can be used
  as a part of a file system path.
  
  Note: this is not designed to duplicate the exact checks that GCS
  would perform on the server side. We make some checks
  that are relevant to using GCS as a file system.
  
  @param objectName Object name to check.
  @param allowEmptyObjectName If true, a missing object name is not considered invalid.