Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

How to join nested collections with Stream API

For example, in in EGit, PushOperationSpecification contains LinkedHashMap<URIish, Collection<RemoteRefUpdate>>. So you can join all remote name with Stream API like:

String specs = this.specification.getURIs().stream()
        .map(uri -> this.specification.getRefUpdates(uri))
                (sb, refupdates) -> sb.append(
                        .map(remote -> remote.getRemoteName())
                (sb1, sb2) -> sb1.append(sb2))