Пример #1
0
  @Test
  public void entryBasicTests() {
    Map.Entry<String, String> kvh1 = Maps2.entry("xyzzy", "plugh");
    Map.Entry<String, String> kvh2 = Maps2.entry("foobar", "blurfl");
    @SuppressWarnings({"unchecked", "rawtypes"})
    Map.Entry<String, String> sie = new AbstractMap.SimpleImmutableEntry("xyzzy", "plugh");

    assertTrue(kvh1.equals(sie));
    assertTrue(sie.equals(kvh1));
    assertFalse(kvh2.equals(sie));
    assertFalse(sie.equals(kvh2));
    assertEquals(sie.hashCode(), kvh1.hashCode());
    assertEquals(sie.toString(), kvh1.toString());
  }
Пример #2
0
  @Test
  public void entry_hashCodeForNullKeyAndValue() {
    MutableMap<Integer, String> map = this.newMapWithKeyValue(null, null);
    Map.Entry<Integer, String> entry = Iterate.getFirst(map.entrySet());

    Assert.assertEquals(0, entry.hashCode());
  }
Пример #3
0
 public int hashCode() {
   return entry.hashCode();
 }