Resource pS = null;
URI pP = null;
Value pO = null;
ArrayList<PatchLine> patch = new ArrayList<>(removals.size()+additions.size());
for (Statement s : removals) {
final WildcardStatement ws = new WildcardStatement(
s.getSubject().equals(pS) ? null : s.getSubject(),
s.getPredicate().equals(pP) ? null : s.getPredicate(),
s.getObject().equals(pO) ? null : s.getObject()
);
patch.add(new PatchLine(PatchLine.Operator.DELETE, ws));
pS = s.getSubject();
pP = s.getPredicate();
pO = s.getObject();
}
for (Statement s : additions) {
final WildcardStatement ws = new WildcardStatement(
s.getSubject().equals(pS) ? null : s.getSubject(),
s.getPredicate().equals(pP) ? null : s.getPredicate(),
s.getObject().equals(pO) ? null : s.getObject()
);
patch.add(new PatchLine(PatchLine.Operator.ADD, ws));