google / data-transfer-project

The Data Transfer Project makes it easy for people to transfer their data between online service providers. We are establishing a common framework, including data models and protocols, to enable direct transfer of data both into and out of participating online service providers.

Home Page:http://datatransferproject.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make size calculation mode more generic

xokker opened this issue · comments

We need a list of downloadable items when calculating the sizes of the items stored in a container resource. Today we do it manually based on the type:

 Collection<? extends DownloadableItem> items;
 if (exportedData instanceof PhotosContainerResource) {
   items = ((PhotosContainerResource) exportedData).getPhotos();
 } else if (exportedData instanceof VideosContainerResource) {
   items = ((VideosContainerResource) exportedData).getVideos();
 } else {
   return;
 }

@jzacsh proposed to replace it with a generic approach. I like this idea, but we need to settle on the implementation.

So far I see a few options:

  • introduce a method List<DownloadableItem> getDownloadableItems() { return ImmutableList.of(); } to ContainerResource;
  • create a new interface (along the lines of ContainerResourceWithDownloadableItems) with the same method signature but no default implementation;
  • abandon the idea and keep maintaining manual if-else block.

cc @wmorland

Is this resolved?