X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.interop%2Fsrc%2Forg%2Fsimantics%2Finterop%2Ftest%2FResourceComparator.java;h=8234998ad546067365c4439bf9c2431c97d5bc4a;hb=8eb962de0cace69cc401dd05d980c0a1501ca260;hp=0b0a7c1a53d983933319bfa901f70eca84ff1ce8;hpb=499167aa0bcc2cab0066b87ef4a690c16ea92754;p=simantics%2Finterop.git diff --git a/org.simantics.interop/src/org/simantics/interop/test/ResourceComparator.java b/org.simantics.interop/src/org/simantics/interop/test/ResourceComparator.java index 0b0a7c1..8234998 100644 --- a/org.simantics.interop/src/org/simantics/interop/test/ResourceComparator.java +++ b/org.simantics.interop/src/org/simantics/interop/test/ResourceComparator.java @@ -1,39 +1,63 @@ -package org.simantics.interop.test; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; - -/** - * - * @author Marko Luukkainen - * - */ -public abstract class ResourceComparator { - - private GraphComparator comparator; - - void setComparator(GraphComparator comparator) { - this.comparator = comparator; - } - - public GraphComparator getComparator() { - return comparator; - } - - /** - * Compares two resources and returns numeric value of differences, minimum value is 1. - * - * Special values: - * Integer.MAX_VALUE: Objects are not comparable. - * 0 (zero): Object comparison is not reliable. - * - * @param g - * @param o1 - * @param o2 - * @return - * @throws DatabaseException - */ - public abstract int compare(ReadGraph g, Resource o1, Resource o2) throws DatabaseException; - -} +package org.simantics.interop.test; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; + +/** + * + * @author Marko Luukkainen + * + */ +public abstract class ResourceComparator { + + private GraphComparator comparator; + + void setComparator(GraphComparator comparator) { + this.comparator = comparator; + } + + public GraphComparator getComparator() { + return comparator; + } + + /** + * Optional initialization method for overriding implementations. + * + * @param g + * @param r1 root 1 + * @param r2 root 2 + */ + public void initialize(ReadGraph g, Resource r1, Resource r2) throws DatabaseException { + + } + + /** + * Compares two resources and returns numeric value of differences, minimum value is 1. + * + * Special values: + * Integer.MAX_VALUE: Objects are not comparable. + * 0 (zero): Object comparison is not reliable. + * + * Result is same as compare(g, o1, o2, true); + * + */ + public abstract int compare(ReadGraph g, Resource o1, Resource o2) throws DatabaseException; + + /** + * Compares two resources and returns numeric value of differences, minimum value is 1. + * + * Special values: + * Integer.MAX_VALUE: Objects are not comparable. + * 0 (zero): Object comparison is not reliable. + * + * @param g + * @param o1 + * @param o2 + * @param local: if true, comparison must not utilise information stored into comparator. + * @return + * @throws DatabaseException + */ + public abstract int compare(ReadGraph g, Resource o1, Resource o2, boolean local) throws DatabaseException; + +}