google/data-transfer-project

Make size calculation mode more generic

xokker opened this issue · 1 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?