@Override
  public Set<K> keySet() {
    Set<IdentityObject<K>> set = mInternalMap.keySet();
    return new Set<K>() {

      @Override
      public int size() {
        return set.size();
      }

      @Override
      public boolean isEmpty() {
        return set.isEmpty();
      }

      @Override
      public boolean contains(Object o) {
        return set.contains(new IdentityObject<>(o));
      }

      @Override
      public Iterator<K> iterator() {
        return set.stream().map(IdentityObject::get).iterator();
      }

      @Override
      public Object[] toArray() {
        throw new UnsupportedOperationException(String.format(UNSUPPORTED_OP_FMT, "toArray"));
      }

      @Override
      public <T> T[] toArray(T[] a) {
        throw new UnsupportedOperationException(String.format(UNSUPPORTED_OP_FMT, "toArray"));
      }

      @Override
      public boolean add(K k) {
        throw new UnsupportedOperationException(String.format(UNSUPPORTED_OP_FMT, "add"));
      }

      @Override
      public boolean remove(Object o) {
        return set.remove(new IdentityObject<>(o));
      }

      /*
       * This method is possible to implement if inputs from the input collection are auto-boxed
       * into an IdentityObject<T> but the implementation has been left absent for now.
       */
      @Override
      public boolean containsAll(Collection<?> c) {
        throw new UnsupportedOperationException(String.format(UNSUPPORTED_OP_FMT, "containsAll"));
      }

      @Override
      public boolean addAll(Collection<? extends K> c) {
        throw new UnsupportedOperationException(String.format(UNSUPPORTED_OP_FMT, "addAll"));
      }

      /*
       * This method is possible to implement if inputs from the input collection are auto-boxed
       * into an IdentityObject<T> but the implementation has been left absent for now.
       */
      @Override
      public boolean retainAll(Collection<?> c) {
        throw new UnsupportedOperationException(String.format(UNSUPPORTED_OP_FMT, "retainAll"));
      }

      /*
       * This method is possible to implement if inputs from the input collection are auto-boxed
       * into an IdentityObject<T> but the implementation has been left absent for now.
       */
      @Override
      public boolean removeAll(Collection<?> c) {
        throw new UnsupportedOperationException(String.format(UNSUPPORTED_OP_FMT, "removeAll"));
      }

      @Override
      public void clear() {
        set.clear();
      }
    };
  }
@Test
  public void keySet() {
    String x = new String("x");
    String xx = new String("x");
    assertNull(mMap.put(x, "x"));
    assertNull(mMap.put(xx, "x2"));
    assertEquals(2, mMap.size());
    Set<String> km = mMap.keySet();
    assertEquals(2, km.size());
    assertTrue(km.contains(x));
    assertTrue(km.contains(xx));
    assertEquals("x", mMap.remove(x));
    assertEquals(1, km.size());
    assertTrue(km.remove(xx));
    assertEquals(0, km.size());
    assertEquals(0, mMap.size());
  }