]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop/src/org/simantics/interop/test/TypeComparator.java
Support for enumerated properties.
[simantics/interop.git] / org.simantics.interop / src / org / simantics / interop / test / TypeComparator.java
index 6c85d284699db0e5db56231a48d9e96439774a6a..2ea03d38f8d12ce0e4519b8b5a2328e906d084e1 100644 (file)
@@ -27,7 +27,7 @@ public class TypeComparator extends ResourceComparator {
        @Override
        public int compare(ReadGraph g, Resource o1, Resource o2, boolean local) throws DatabaseException {
                if (o1.equals(o2)) {
-                       return 1;
+                       return EXACT_MATCH;
                }
                return compare(g, o1, o2);
        }
@@ -35,7 +35,7 @@ public class TypeComparator extends ResourceComparator {
        @Override
        public int compare(ReadGraph g, Resource o1, Resource o2) throws DatabaseException{
                if (!compareType(g,o1, o2)) {
-                       return (Integer.MAX_VALUE);
+                       return NO_MATCH;
                }
                return propsDiffCount(g,o1, o2);
        }
@@ -60,6 +60,16 @@ public class TypeComparator extends ResourceComparator {
                                return false;
                        }
                }
+               if (rs1.size() == 1) {
+                       // Check for enumeration type. Without this enumeration instances could be mixed together.
+                       if (g.hasStatement(rs1.get(0), l0.Enumeration, rs1.get(0))) {
+                               if (!r1.equals(r2)) {
+                                       rs1.clear();
+                                       rs2.clear();
+                                       return false;
+                               }
+                       }
+               }
                
                rs1.clear();
                rs2.clear();