Created
October 27, 2020 23:11
-
-
Save MazizEsa/7b3af75773238f8462dee3cf3feacc6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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