1 package org.simantics.interop.test;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.exception.DatabaseException;
9 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
12 public abstract class ResourceComparator {
14 public static int NO_MATCH = Integer.MAX_VALUE; // Comparison result when Resources cannot match.
15 public static int UNDECISIVE = 0; // Comparison result when current available data is not enough to decide if the Resources match or not.
16 public static int EXACT_MATCH = 1; // Comparison result when Resources are exact match.
18 private GraphComparator comparator;
20 void setComparator(GraphComparator comparator) {
21 this.comparator = comparator;
24 public GraphComparator getComparator() {
29 * Optional initialization method for overriding implementations.
35 public void initialize(ReadGraph g, Resource r1, Resource r2) throws DatabaseException {
40 * Compares two resources and returns numeric value of differences, minimum value is 1.
43 * Integer.MAX_VALUE: Objects are not comparable.
44 * 0 (zero): Object comparison is not reliable.
46 * Result is same as compare(g, o1, o2, true);
49 public abstract int compare(ReadGraph g, Resource o1, Resource o2) throws DatabaseException;
52 * Compares two resources and returns numeric value of differences, minimum value is 1.
55 * Integer.MAX_VALUE: Objects are not comparable.
56 * 0 (zero): Object comparison is not reliable.
61 * @param local: if true, comparison must not utilise information stored into comparator.
63 * @throws DatabaseException
65 public abstract int compare(ReadGraph g, Resource o1, Resource o2, boolean local) throws DatabaseException;