티스토리 뷰

반응형
  • mulityKeyMap

    • com.google.guava에서 제공되는 map 인터페이스로, 각 key에 해당되는 콜렉션을 보유합니다.
  • mulityKeyMap.get()
    hashmap, MultiMap의 경우 get(key)로 데이터를 가지고 왔을때 매핑 되는 정보가 없다면 null을 리턴해준다.
    mulityKeyMap도 매핑된 데이터가 없을 경우 null을 리턴한다고 생각하고 null 체크를 하고 테스트를 돌려봤다.

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;

public class Test {
  @Test
  public void multiKeyMapNullCheck_test() {
      Multimap<String, String> nullMap = ArrayListMultimap.create();
      assertNull(nullMap.get("noneMatchedkey"));
  }
}
      java.lang.AssertionError: expected null, but was:<\[\]>
        at org.junit.Assert.failNotNull(Assert.java:664)
        at org.junit.Assert.assertNull(Assert.java:646)
        at org.junit.Assert.assertNull(Assert.java:656)
        at CommonTest.multiKeyMapNullCheck_test(CommonTest.java:1242)

띠용

/**
* Returns a view collection of the values associated with {@code key} in this
* multimap, if any. Note that when {@code containsKey(key)} is false, this 
* returns an empty collection, not {@code null}.
*
* <p>Changes to the returned collection will update the underlying multimap,
* and vice versa.
*/
Collection<V> get(@Nullable K key);
반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함