org.javers.core.diff.GraphPair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-core Show documentation
Show all versions of javers-core Show documentation
JaVers - object auditing and diff framework for Java
package org.javers.core.diff;
import org.javers.core.graph.ObjectNode;
import java.util.Collections;
import java.util.Set;
import static org.javers.common.collections.Sets.difference;
/**
* @author bartosz walacik
*/
public class GraphPair {
private final ObjectGraph leftGraph;
private final ObjectGraph rightGraph;
private final Set onlyOnLeft;
private final Set onlyOnRight;
public GraphPair(ObjectGraph leftGraph, ObjectGraph rightGraph) {
this.leftGraph = leftGraph;
this.rightGraph = rightGraph;
this.onlyOnLeft = difference(leftGraph.nodes(), rightGraph.nodes());
this.onlyOnRight = difference(rightGraph.nodes(), leftGraph.nodes());
}
//for initial
public GraphPair(ObjectGraph currentGraph) {
this.leftGraph = new EmptyGraph();
this.rightGraph = currentGraph;
this.onlyOnLeft = Collections.emptySet();
this.onlyOnRight = rightGraph.nodes();
}
private class EmptyGraph extends ObjectGraph {
EmptyGraph() {
super(Collections.emptySet());
}
}
public Set getOnlyOnLeft() {
return onlyOnLeft;
}
public Set getOnlyOnRight() {
return onlyOnRight;
}
public Set getLeftNodeSet() {
return leftGraph.nodes();
}
public Set getRightNodeSet() {
return rightGraph.nodes();
}
}