data-transfer-project icon indicating copy to clipboard operation
data-transfer-project copied to clipboard

Make size calculation mode more generic

Open xokker opened this issue 2 years ago • 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

xokker avatar Jul 04 '22 15:07 xokker

Is this resolved?

Higgs32584 avatar Mar 26 '23 05:03 Higgs32584