Skip to content

Instantly share code, notes, and snippets.

@MazizEsa
Created October 27, 2020 23:11
Show Gist options
  • Save MazizEsa/7b3af75773238f8462dee3cf3feacc6f to your computer and use it in GitHub Desktop.
Save MazizEsa/7b3af75773238f8462dee3cf3feacc6f to your computer and use it in GitHub Desktop.
public void buildThumbnailWithUrl() {
final List<Thumbnail> rawThumbnailList = getThumbnailListFromSomeWhere();
final String appropriateCdn = getTheRightCdnBasedOnRegion();
final String defaultCdn = getDefaultCdn();
final List<Thumbnail> thumbnailListWithCdn = rawThumbnailList.stream().map(eachThumbnail -> {
final String cdnChose = eachThumbnail.isHasLarge() ? defaultCdn : appropriateCdn;
eachThumbnail.setThumbnailUri(cdnChose + eachThumbnail.getThumbnailUri());
return eachThumbnail;
}).collect(Collectors.toList());
final List<ThumbnailResponse> responseData = thumbnailListWithCdn.stream()
.map(eachThumbnail -> ThumbnailResponse.builder().thumbnailUrl(eachThumbnail.getThumbnailUri()).build())
.collect(Collectors.toList());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment