UpdateOp { void containsMapEntry(@NotNull String property, @NotNull Revision revision, boolean exists) { if (isNew) { throw new IllegalStateException("Cannot use containsMapEntry() on new document"); } Condition c = exists ? Condition.EXISTS : Condition.MISSING; getOrCreateConditions().put(new Key(property, checkNotNull(revision)), c); } UpdateOp(@NotNull String id, boolean isNew);   UpdateOp(@NotNull String id,
             boolean isNew,
             boolean isDelete,
             @NotNull Map<Key, Operation> changes,
             @Nullable Map<Key, Condition> conditions); UpdateOp shallowCopy(String id); UpdateOp copy(); @NotNull String getId(); boolean isNew(); void setNew(boolean isNew); Map<Key, Operation> getChanges(); Map<Key, Condition> getConditions(); boolean hasChanges(); void remove(@NotNull String property); void removeMapEntry(@NotNull String property, @NotNull Revision revision); void set(String property, long value); void set(String property, boolean value); void set(String property, String value); void increment(@NotNull String property, long value); UpdateOp getReverseOperation(); @Override String toString();  }
@Test public void containsMapEntry() { Revision r = Revision.newRevision(1); UpdateOp op = new UpdateOp("id", true); try { op.containsMapEntry("p", r, true); fail("expected " + IllegalStateException.class.getName()); } catch (IllegalStateException e) { } op = new UpdateOp("id", false); op.containsMapEntry("p", r, true); assertEquals(1, op.getConditions().size()); UpdateOp.Key key = op.getConditions().keySet().iterator().next(); assertEquals(r, key.getRevision()); assertEquals("p", key.getName()); UpdateOp.Condition c = op.getConditions().get(key); assertEquals(UpdateOp.Condition.EXISTS, c); op = new UpdateOp("id", false); op.containsMapEntry("p", r, false); assertEquals(1, op.getConditions().size()); key = op.getConditions().keySet().iterator().next(); assertEquals(r, key.getRevision()); assertEquals("p", key.getName()); c = op.getConditions().get(key); assertEquals(UpdateOp.Condition.MISSING, c); }