test_class.file: oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/UpdateUtilsTest.java
test_class.identifier: UpdateUtilsTest
test_case.body: @Test
      public void applyChanges() {
          Revision r = Revision.newRevision(1);
          String id = Utils.getIdFromPath("/foo");
          Document d = new Document();
          d.put(Document.ID, id);
  
          UpdateOp op = newUpdateOp(id);
          op.set("p", 42L);
  
          UpdateUtils.applyChanges(d, op);
          assertEquals(42L, d.get("p"));
  
          op = newUpdateOp(id);
          op.max("p", 23L);
  
          UpdateUtils.applyChanges(d, op);
          assertEquals(42L, d.get("p"));
  
          op = newUpdateOp(id);
          op.max("p", 58L);
  
          UpdateUtils.applyChanges(d, op);
          assertEquals(58L, d.get("p"));
  
          op = newUpdateOp(id);
          op.increment("p", 3);
  
          UpdateUtils.applyChanges(d, op);
          assertEquals(61L, d.get("p"));
  
          op = newUpdateOp(id);
          op.setMapEntry("t", r, "value");
  
          UpdateUtils.applyChanges(d, op);
          assertEquals("value", getMapEntry(d, "t", r));
  
          op = newUpdateOp(id);
          op.removeMapEntry("t", r);
  
          UpdateUtils.applyChanges(d, op);
          assertNull(getMapEntry(d, "t", r));
      }
test_case.class_method_signature: UpdateUtilsTest.applyChanges()
test_case.full_signature: @Test public void applyChanges()
test_case.identifier: applyChanges
test_case.invocations: newRevision getIdFromPath put newUpdateOp set applyChanges assertEquals get newUpdateOp max applyChanges assertEquals get newUpdateOp max applyChanges assertEquals get newUpdateOp increment applyChanges assertEquals get newUpdateOp setMapEntry applyChanges assertEquals getMapEntry newUpdateOp removeMapEntry applyChanges assertNull getMapEntry
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void applyChanges()
focal_class.file: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/UpdateUtils.java
focal_class.identifier: UpdateUtils
focal_class.class_method_signature: UpdateUtils.applyChanges(@NotNull Document doc,
                                      @NotNull UpdateOp update)
focal_class.full_signature: public static void applyChanges(@NotNull Document doc,
                                      @NotNull UpdateOp update)
focal_class.identifier: applyChanges
focal_class.modifiers: public static
focal_class.parameters: (@NotNull Document doc,
                                      @NotNull UpdateOp update)
focal_class.return: void
focal_class.signature: void applyChanges(@NotNull Document doc,
                                      @NotNull UpdateOp update)
focal_class.class_method_signature: UpdateUtils.checkConditions(@NotNull Document doc,
                                            @NotNull Map<Key, Condition> conditions)
focal_class.full_signature: public static boolean checkConditions(@NotNull Document doc,
                                            @NotNull Map<Key, Condition> conditions)
focal_class.identifier: checkConditions
focal_class.modifiers: public static
focal_class.parameters: (@NotNull Document doc,
                                            @NotNull Map<Key, Condition> conditions)
focal_class.return: boolean
focal_class.signature: boolean checkConditions(@NotNull Document doc,
                                            @NotNull Map<Key, Condition> conditions)
focal_class.class_method_signature: UpdateUtils.assertUnconditional(@NotNull UpdateOp up)
focal_class.full_signature: public static void assertUnconditional(@NotNull UpdateOp up)
focal_class.identifier: assertUnconditional
focal_class.modifiers: public static
focal_class.parameters: (@NotNull UpdateOp up)
focal_class.return: void
focal_class.signature: void assertUnconditional(@NotNull UpdateOp up)
focal_method.body: public static void applyChanges(@NotNull Document doc,
                                      @NotNull UpdateOp update) {
          doc.put(Document.ID, update.getId());
          for (Entry<Key, Operation> e : checkNotNull(update).getChanges().entrySet()) {
              Key k = e.getKey();
              Operation op = e.getValue();
              switch (op.type) {
                  case SET: {
                      doc.put(k.toString(), op.value);
                      break;
                  }
                  case REMOVE: {
                      doc.remove(k.toString());
                      break;
                  }
                  case MAX: {
                      Comparable newValue = (Comparable) op.value;
                      Object old = doc.get(k.toString());
                      //noinspection unchecked
                      if (old == null || newValue.compareTo(old) > 0) {
                          doc.put(k.toString(), op.value);
                      }
                      break;
                  }
                  case INCREMENT: {
                      Object old = doc.get(k.toString());
                      Long x = (Long) op.value;
                      if (old == null) {
                          old = 0L;
                      }
                      doc.put(k.toString(), ((Long) old) + x);
                      break;
                  }
                  case SET_MAP_ENTRY: {
                      Object old = doc.get(k.getName());
                      @SuppressWarnings("unchecked")
                      Map<Revision, Object> m = (Map<Revision, Object>) old;
                      if (m == null) {
                          m = new TreeMap<Revision, Object>(StableRevisionComparator.REVERSE);
                          doc.put(k.getName(), m);
                      }
                      if (k.getRevision() == null) {
                          throw new IllegalArgumentException("Cannot set map entry " + k.getName() + " with null revision");
                      }
                      m.put(k.getRevision(), op.value);
                      break;
                  }
                  case REMOVE_MAP_ENTRY: {
                      Object old = doc.get(k.getName());
                      @SuppressWarnings("unchecked")
                      Map<Revision, Object> m = (Map<Revision, Object>) old;
                      if (m != null) {
                          m.remove(k.getRevision());
                      }
                      break;
                  }
              }
          }
      }
focal_method.class_method_signature: UpdateUtils.applyChanges(@NotNull Document doc,
                                      @NotNull UpdateOp update)
focal_method.full_signature: public static void applyChanges(@NotNull Document doc,
                                      @NotNull UpdateOp update)
focal_method.identifier: applyChanges
focal_method.invocations: put getId entrySet getChanges checkNotNull getKey getValue put toString remove toString get toString compareTo put toString get toString put toString get getName put getName getRevision getName put getRevision get getName remove getRevision
focal_method.modifiers: public static
focal_method.parameters: (@NotNull Document doc,
                                      @NotNull UpdateOp update)
focal_method.return: void
focal_method.signature: void applyChanges(@NotNull Document doc,
                                      @NotNull UpdateOp update)