code: public static String matchListPrefix(
        String objectNamePrefix, String delimiter, String objectName) {
      Preconditions.checkArgument(!Strings.isNullOrEmpty(objectName),
          "objectName must not be null or empty, had args %s/%s/%s: ",
              objectNamePrefix, delimiter, objectName);
  
      // The suffix that we'll use to check for the delimiter is just the whole name if no prefix
      // was supplied.
      String suffix = objectName;
      int suffixIndex = 0;
      if (objectNamePrefix != null) {
        // The underlying GCS API does return objectName when it equals the prefix, but our
        // GoogleCloudStorage wrapper filters this case if the objectName also ends with
        // PATH_DELIMITER.
        if (!objectName.startsWith(objectNamePrefix)
            || (objectName.equals(objectNamePrefix) && objectNamePrefix.endsWith(PATH_DELIMITER))) {
          return null;
        } else {
          suffixIndex = objectNamePrefix.length();
          suffix = objectName.substring(suffixIndex);
        }
      }
      if (!Strings.isNullOrEmpty(delimiter) && suffix.contains(delimiter)) {
        // Return the full prefix and suffix up through first occurrence of delimiter after
        // the prefix, inclusive of the delimiter.
        objectName = objectName.substring(
            0, objectName.indexOf(delimiter, suffixIndex) + delimiter.length());
      }
      return objectName;
    }
docs: Helper that mimics the GCS API behavior for taking an existing objectName and checking if it
  matches a user-supplied prefix with an optional directory "delimiter". If it matches, either
  the full objectName will be returned unmodified, or the return value will be a String that
  is a prefix of the objectName inclusive of the matching prefix but truncating any suffix past
  the first appearance of the delimiter after the full prefix. The returned prefix includes
  the delimiter String at which the objectName was truncated.
  
  @param objectNamePrefix The prefix that {@code objectName} must match to be returned in any
  form. May be null; then an objectName will always be returned, just possibly truncated.
  @param delimiter The delimiter (usually a directory separator, e.g. '/') at which to truncate
  the returned objectName after including the matched prefix. May be null for no truncation.
  @param objectName The name to attempt to match against the prefix and delimiter.
  @return A substring of objectName or the full unaltered objectName after applying GCS matching
  logic, or null if the supply objectName does not match the provided prefix.