Skip to content

Instantly share code, notes, and snippets.

@mindwing
Created June 8, 2016 05:15
Show Gist options
  • Save mindwing/1fe8efda31d0e3c6435e7e49aad5f640 to your computer and use it in GitHub Desktop.
Save mindwing/1fe8efda31d0e3c6435e7e49aad5f640 to your computer and use it in GitHub Desktop.
// For type clarity only, the following are smaller, reused operators:
Function<String, DataBlob> urlToBlob = …;
Function<DataBlob, List<ItemBlob>> blobToItemBlobs = …;
Predicate<ItemBlob> activeOnly = …;
Function<ItemBlob, UiModel> itemBlobToUiModel = …;
Function<List<UiModel>, List<UiModel>> sortByDateDesc = …;
Function<String, List<UiModel>> urlToUiModels =
Functions.functionFrom(String.class)
.apply(urlToBlob)
.unpack(blobToItemBlobs)
.filter(activeOnly)
.map(itemBlobToUiModel)
.morph(sortByDateDesc)
.thenLimit(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment