copyOf metodu
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
List<String> temp = Stream.of("b, c", "a", " ", "a, c")
.filter(StringUtils::isNotBlank)
.map(val -> val.split(","))
.flatMap(Arrays::stream)
.map(String::trim)
.collect(Collectors.toList());
Multiset<String> multiset = ImmutableSortedMultiset.copyOf(temp);
System.out.println("As list: " + temp);
System.out.println("As multiset: " + multiset);
// Output is:
// As list: [b, c, a, a, c]
// As multiset: [a x 2, b, c x 2]
naturalOrder metoduŞöyle yaparız.
.collect(Collector.of(
ImmutableSortedMultiset::<String>naturalOrder,
ImmutableSortedMultiset.Builder::add,
(b1, b2) -> {b1.addAll(b2.build()); return b1;},
ImmutableSortedMultiset.Builder::build)
);
toImmutableSortedMultiset metoduŞöyle yaparız.
.collect(ImmutableSortedMultiset.toImmutableSortedMultiset(Comparator.naturalOrder()));
Hiç yorum yok:
Yorum Gönder