Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Latest commit

 

History

History
48 lines (34 loc) · 1.25 KB

README.md

File metadata and controls

48 lines (34 loc) · 1.25 KB

docs

Optional

Collections and Streams

Streams

Stream of Stream

final Stream<Stream<String>> streamStream = createStreameSomeHow();
final List<String> result = streamStream
        .reduce(Stream.empty(), Stream::concat)
        .collect(toList());

Lists

partition

final List<String> list = asList("a", "ba", "aaa", "baaa", "aaa", "ba");
final Map<Boolean, List<String>> map = list.stream()
    .collect(Collectors.partitioningBy(s -> s.startsWith("a")));
assertThat(map.get(true)).contains("a", "aaa", "aaa");
assertThat(map.get(false)).contains("ba", "baaa", "ba");

Lambda Functions and closures

Weird stuff

final Predicate<String> predicate = "GET"::equals;

CompletableFuture and CompletionStage

Articles