Last active
November 11, 2016 10:10
-
-
Save amatkivskiy/3c775b23b092e2b36bbd65b97a893bc9 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 int findFirstValue(List<MediaItem> items) { | |
return Stream.stream(items) | |
.filter(new Func1<MediaItem, Boolean>() { | |
@Override | |
public Boolean call(MediaItem item) { | |
return item.isActive; | |
} | |
}) | |
.map(new Func1<MediaItem, Pair<Integer, String>>() { | |
@Override | |
public Pair<Integer, String> call(MediaItem item) { | |
return new Pair<>(item.id, item.name); | |
} | |
}).sort(new Comparator<Pair<Integer, String>>() { | |
@Override | |
public int compare(Pair<Integer, String> one, Pair<Integer, String> another) { | |
return Integer.compare(one.first, another.first); | |
} | |
}).first().get().first; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment