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..
Collector metodudur
ImmutableSet.Builder nesnesi döner.
copyOf metodu
Şöyle yaparız..
ImmutableSet.copyOf(heroes)
toImmutableSet metoduCollector metodudur
Örnek
Şöyle yaparız.
collections
.stream()
.flatMap(collection -> loadKeys(...).stream())
.collect(ImmutableSet.toImmutableSet());
Hiç yorum yok:
Yorum Gönder