IdentityExtractor idex) throws InvalidArrayIdentity, DuplicateArrayIdentity { Difference<BaseType> ret = new Difference<>(); ret.add(new Removal(field1, getElement(node1, entry1.getValue()))); } else { field2.push(index2); ret.add(new Move(field1, field2, getElement(node1, entry1.getValue()))); ret.add(compareNodes(field1, getElement(node1, entry1.getValue()), field2, getElement(node2, index2))); field2.pop(); ret.add(new Addition(field2, getElement(node2, entry2.getValue()))); field2.pop();
/** * Records the amount of difference between the nodes last returned by * next(). Also stores the minumum amount of difference for node1 */ public void recordDistance(int index1, int index2, Difference diff) { double change = diff.getChangeAmount(); IxDiff m = minimums1.get(index1); if (m == null || m.change > change) { minimums1.put(index1, m = new IxDiff(diff, change, index1, index2)); } }
ArrayType node2) throws InvalidArrayIdentity, DuplicateArrayIdentity { Difference<BaseType> ret = new Difference<>(); IndexAssoc assoc = new IndexAssoc(size(node1), size(node2)); HashSet<Pair> comparedPairs = new HashSet<>(); if (diff.same()) { assoc.associate(index1, index2); field2.pop(); ret.add(new Removal(field1, element1)); assoc.remove1(index1); } else { ret.add(ixdiff.diff); BaseType element2 = getElement(node2, index); field2.push(index); ret.add(new Addition(field2, element2)); field2.pop(); field2.push(entry.getValue()); BaseType node = getElement(node1, entry.getKey()); ret.add(new Move(field1, field2, node)); field2.pop(); field1.pop();
ArrayType node2) throws InvalidArrayIdentity, DuplicateArrayIdentity { Difference<BaseType> ret = new Difference<>(); IndexAssoc assoc = new IndexAssoc(size(node1), size(node2)); HashSet<Pair> comparedPairs = new HashSet<>(); if (diff.same()) { assoc.associate(index1, index2); field2.pop(); ret.add(new Removal(field1, element1)); assoc.remove1(index1); } else { ret.add(ixdiff.diff); BaseType element2 = getElement(node2, index); field2.push(index); ret.add(new Addition(field2, element2)); field2.pop(); field2.push(entry.getValue()); BaseType node = getElement(node1, entry.getKey()); ret.add(new Move(field1, field2, node)); field2.pop(); field1.pop();
for(DocComparator.Delta<JsonNode> delta : diff.getDelta()) { if (delta instanceof DocComparator.Move && arrayOrderSignificant) { JsonNode movedNode = ((DocComparator.Move<JsonNode>) delta).getMovedNode();
for (DocComparator.Delta<JsonNode> d : diff.getDelta()) { if ((d instanceof DocComparator.Addition && ((DocComparator.Addition<JsonNode>) d).getAddedNode().isValueNode())
for (DocComparator.Delta<JsonNode> d : diff.getDelta()) { if ((d instanceof DocComparator.Addition && ((DocComparator.Addition<JsonNode>) d).getAddedNode().isValueNode())
IdentityExtractor idex) throws InvalidArrayIdentity, DuplicateArrayIdentity { Difference<BaseType> ret = new Difference<>(); ret.add(new Removal(field1, getElement(node1, entry1.getValue()))); } else { field2.push(index2); ret.add(new Move(field1, field2, getElement(node1, entry1.getValue()))); ret.add(compareNodes(field1, getElement(node1, entry1.getValue()), field2, getElement(node2, index2))); field2.pop(); ret.add(new Addition(field2, getElement(node2, entry2.getValue()))); field2.pop();
ObjectType node2) throws InvalidArrayIdentity, DuplicateArrayIdentity { Difference<BaseType> ret = new Difference<>(); ret.add(compareNodes(field1, value1, field2, value2)); field2.pop(); } else { ret.add(new Removal(field1, value1)); if (!hasField(node1, fieldName)) { field2.push(fieldName); ret.add(new Addition(field2, field.getValue())); field2.pop();
ObjectType node2) throws InvalidArrayIdentity, DuplicateArrayIdentity { Difference<BaseType> ret = new Difference<>(); ret.add(compareNodes(field1, value1, field2, value2)); field2.pop(); } else { ret.add(new Removal(field1, value1)); if (!hasField(node1, fieldName)) { field2.push(fieldName); ret.add(new Addition(field2, field.getValue())); field2.pop();
if(!diff.same()) { if(diff.getNumChangedFields()>0 || arrayOrderingSignificant) { LOGGER.debug("Watched fields changed, creating notification"); NotificationEntity notification =
public Difference<BaseType> compareNodes(MutablePath field1, BaseType node1, MutablePath field2, BaseType node2) throws InvalidArrayIdentity, DuplicateArrayIdentity { if (isValue(node1) && isValue(node2)) { if (!equals(asValue(node1), asValue(node2))) { return new Difference(new Modification(field1, node1, field2, node2)); } } else if (isArray(node1) && isArray(node2)) { return compareArrays(field1, asArray(node1), field2, asArray(node2)); } else if (isObject(node1) && isObject(node2)) { return compareObjects(field1, asObject(node1), field2, asObject(node2)); } else if (!(isNull(node1) && isNull(node2))) { return new Difference<>(new Modification(field1, node1, field2, node2)); } return new Difference<>(1); }
public Difference<BaseType> compareNodes(MutablePath field1, BaseType node1, MutablePath field2, BaseType node2) throws InvalidArrayIdentity, DuplicateArrayIdentity { if (isValue(node1) && isValue(node2)) { if (!equals(asValue(node1), asValue(node2))) { return new Difference(new Modification(field1, node1, field2, node2)); } } else if (isArray(node1) && isArray(node2)) { return compareArrays(field1, asArray(node1), field2, asArray(node2)); } else if (isObject(node1) && isObject(node2)) { return compareObjects(field1, asObject(node1), field2, asObject(node2)); } else if (!(isNull(node1) && isNull(node2))) { return new Difference<>(new Modification(field1, node1, field2, node2)); } return new Difference<>(1); }
/** * Constructs a difference with one modification, no unchanged fields */ public Difference(Delta<T> d) { this(new ArrayList<Delta<T>>(1)); add(d); }
/** * Records the amount of difference between the nodes last returned by * next(). Also stores the minumum amount of difference for node1 */ public void recordDistance(int index1, int index2, Difference diff) { double change = diff.getChangeAmount(); IxDiff m = minimums1.get(index1); if (m == null || m.change > change) { minimums1.put(index1, m = new IxDiff(diff, change, index1, index2)); } }
/** * Constructs a difference with one modification, no unchanged fields */ public Difference(Delta<T> d) { this(new ArrayList<Delta<T>>(1)); add(d); }