21 Ağustos 2019 Çarşamba

ImmutableMap.Builder Sınıfı

build metodu
Örnek
Şöyle yaparız.
ImmutableMap.Builder<String,String> myMap = ImmutableMap.<String, String>builder()
    .put("key1", "value1") 
    .put("key2", "value2") 
    .put("key3", "value3") 
    .put("key4", "value4") 
    .put("key5", "value5") 
    .put("key6", "value6") 
    .put("key7", "value7") 
    .put("key8", "value8") 
    .put("key9", "value9")
    .build();
put metodu
Örnek
Şöyle yaparız.
final Map<String, Integer> m = ImmutableMap.<String, Integer>builder().
      put("a", 1).
      put("b", 2).
      build();
putAll metodu
Şöyle yaparız.
Map<String, String> srcMap = Map.of("A", "a", "B", "b", "C", "c");

ImmutableMap<String, String> map = ImmutableMap.<String, String> builder()
  .putAll(srcMap)
  .put("D", "d")
  .build();

Hiç yorum yok:

Yorum Gönder