Skip to content

Instantly share code, notes, and snippets.

@CremboC
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CremboC/40c8b239fe1b713be480 to your computer and use it in GitHub Desktop.
Save CremboC/40c8b239fe1b713be480 to your computer and use it in GitHub Desktop.
@Override
public Set<Sample> samplesFromGroups(Collection<Long> ids) {
return repository.findAllByIdIn(ids) // get all groups
.stream()
.map(Group::getSamples) // get samples of each group
.flatMap(Set::stream) // flatten into a single set of samples
.collect(toSet());
}
@Override
public Set<Sample> samplesFromGroups(Collection<Long> ids) {
return repository.findAllByIdIn(ids) // get all groups
.stream()
.map(group -> group.getSamples()) // get samples of each group
.flatMap(Set::stream) // flatten into a single set of samples
.collect(toSet());
}
@Override
public Set<Sample> samplesFromGroups(Collection<Long> ids) {
return repository.findAllByIdIn(ids) // get all groups
.stream()
.map(new Function<Group, Set<Sample>>() {
@Override
public Set<Sample> apply(Group group) {
return group.getSamples();
}
}) // get samples of each group
.flatMap(Set::stream) // flatten into a single set of samples
.collect(toSet());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment