IndexedKeyTreeMap extends KeyTreeMap<T> { @Override protected T remove(final UUIDKey uuidKey) { final T remove = super.remove(uuidKey); if (remove != null) { doForAll(remove.getIndex(), new Callback<T>() { @Override public void callback(final T t) { t.setIndex(t.getIndex() - 1); } }); } return remove; } IndexedKeyTreeMap(final KeyDefinition... keyIDs); void put(final T object,
                    final int index); @Override void put(final T object);  }
@Test public void testRemove() throws Exception { toni.uuidKey.retract(); assertEquals(eder, map.get(IndexKey.INDEX_ID).get(new Value(0)).iterator().next()); assertEquals(michael, map.get(IndexKey.INDEX_ID).get(new Value(1)).iterator().next()); eder.uuidKey.retract(); Person next = map.get(IndexKey.INDEX_ID).get(new Value(0)).iterator().next(); assertEquals(michael, next); }