void ensureAlbumSize(int maxSize) {
    if (maxSize == -1) {
      // No max size; no need to go through that code.
      return;
    }
    // Group photos by albumId
    Map<String, List<PhotoModel>> albumGroups =
        photos.stream()
            .filter(photo -> photo.getAlbumId() != null)
            .collect(Collectors.groupingBy(PhotoModel::getAlbumId));
    // Go through groups, splitting up anything that's too big
    for (Entry<String, List<PhotoModel>> entry : albumGroups.entrySet()) {
      List<PhotoModel> photosOfCurrentAlbum = entry.getValue();
      if (photosOfCurrentAlbum.size() > maxSize) {
        for (PhotoAlbum album : albums) {
          if (!album.getId().equals(entry.getKey())) {
            continue;
          }
          // Create new partial album objects and reassign photos to those albums
          List<PhotoAlbum> newAlbums =
              album.split(-Math.floorDiv(-photosOfCurrentAlbum.size(), maxSize));
          Iterator<PhotoModel> remainingPhotos = photosOfCurrentAlbum.iterator();
          for (PhotoAlbum newAlbum : newAlbums) {
            for (int i = 0; i < maxSize; i++) {
              remainingPhotos.next().reassignToAlbum(newAlbum.getId());
              if (!remainingPhotos.hasNext()) {
                break;
              }
            }
          }

          // Replace original album in state
          List<PhotoAlbum> albums_ = new ArrayList<>(albums);
          albums_.remove(album);
          albums_.addAll(newAlbums);
          this.albums = albums_;
        }
      }
    }
  }
A Wrapper for all the possible objects that can be returned by a photos exporter.
portability-types-common/src/main/java/org/datatransferproject/types/common/models/photos/PhotosContainerResource.java