10 Temmuz 2019 Çarşamba

ImmutableSet Sınıfı - Preserve Insertion Order

Giriş
Açıklaması şöyle
Guava’simmutable collections do not allow null elements (and, for maps, null values nor null keys). While this prevents a few use cases, in general it’s quite useful to know that you cannot have null elements in a collection.

They also preserve insertion order: an ImmutableSet can be iterated upon in the insertion order.
build metodu
ImmutableSet.Builder nesnesi döner.

copyOf metodu
Şöyle yaparız..
ImmutableSet.copyOf(heroes)
toImmutableSet metodu
Collector metodudur
Örnek
Şöyle yaparız.
collections
  .stream()
  .flatMap(collection -> loadKeys(...).stream())
  .collect(ImmutableSet.toImmutableSet());

Hiç yorum yok:

Yorum Gönder