public static <K, V> HashMap<K, V> ofHashMap(Object... kv) {
    if (kv == null || kv.length == 0) {
      throw new IllegalArgumentException("entries got no objects, which aren't pairs");
    }
    if ((kv.length & 1) != 0) {
      throw new IllegalArgumentException(
          String.format("entries got %d objects, which aren't pairs", kv.length));
    }
    int size = kv.length >> 1;
    HashMap map = new HashMap<>(size);
    for (int i = 0; i < kv.length; i += 2) {
      map.put(kv[i], kv[i + 1]);
    }
    return map;
  }
@Test
  public void testOfHashMap() {
    assertEquals(Collections.ofHashMap(1, 2, 3, 4), new HashMap<>(ImmutableMap.of(1, 2, 3, 4)));
  }