code: public static StorageResourceId fromObjectName(String objectName, long generationId) {
      Matcher matcher = OBJECT_NAME_IN_GCS_PATTERN.matcher(objectName);
      checkArgument(matcher.matches(), "'%s' is not a valid GCS object name.", objectName);
  
      String bucketName = matcher.group(2);
      String relativePath = matcher.group(4);
      if (bucketName == null) {
        checkArgument(generationId == UNKNOWN_GENERATION_ID,
            "Cannot specify generationId '%s' for root object '%s'", generationId, objectName);
        return ROOT;
      } else if (relativePath != null) {
        return new StorageResourceId(bucketName, relativePath, generationId);
      }
      checkArgument(generationId == UNKNOWN_GENERATION_ID,
          "Cannot specify generationId '%s' for bucket '%s'", generationId, objectName);
      return new StorageResourceId(bucketName);
    }
docs: Parses {@link StorageResourceId} from specified string and generationId.