code: private long getWriteGeneration(StorageResourceId resourceId, boolean overwritable)
        throws IOException {
      logger.atFine().log("getWriteGeneration(%s, %s)", resourceId, overwritable);
      GoogleCloudStorageItemInfo info = getItemInfo(resourceId);
      if (!info.exists()) {
        return 0L;
      }
      if (info.exists() && overwritable) {
        long generation = info.getContentGeneration();
        Preconditions.checkState(generation != 0, "Generation should not be 0 for an existing item");
        return generation;
      }
      throw new FileAlreadyExistsException(String.format("Object %s already exists.", resourceId));
    }
docs: Gets the object generation for a Write operation
  
  @param resourceId object for which generation info is requested
  @return the generation of the object
  @throws IOException if the object already exists and cannot be overwritten