9 Eylül 2019 Pazartesi

ImmutableMultiset Sınıfı

asList metodu
Şöyle yaparız
Set<Character> first = ImmutableSet.of('a', 'b', 'c');
Set<Character> second = ImmutableSet.of('b', 'c', 'd');

// here it's ugly but maybe you can collect to set in the first place
ImmutableMultiset<Character> set = ImmutableSet.<Character>builder()
             .addAll(first)
             .addAll(second)
             .build(); // [a, b, c, d]

List<Character> characters = set.asList();

assertThat(characters).containsOnly('a', 'b', 'c', 'd');
copyOf metodu
Elimizde şöyle bir kod olsun.
List<BigDecimal> listOfNumbers= ...;
Şöyle yaparız.
BigDecimal mostCommon = 
    Multisets.copyHighestCountFirst(ImmutableMultiset.copyOf(listOfNumbers))
        .iterator().next();

Hiç yorum yok:

Yorum Gönder