]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/HasInstanceOfTest.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui.model / src / org / simantics / browsing / ui / model / tests / HasInstanceOfTest.java
diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/HasInstanceOfTest.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/HasInstanceOfTest.java
new file mode 100644 (file)
index 0000000..0d5ea67
--- /dev/null
@@ -0,0 +1,26 @@
+package org.simantics.browsing.ui.model.tests;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class HasInstanceOfTest implements Test {\r
+    Resource type;\r
+\r
+    public HasInstanceOfTest(Resource type) {\r
+        this.type = type;\r
+    }\r
+\r
+    @Override\r
+    public boolean isCompatible(Class<?> contentType) {\r
+        return contentType == Resource.class;\r
+    }\r
+\r
+    @Override\r
+    public boolean test(ReadGraph graph, Object content)\r
+            throws DatabaseException {\r
+        return graph.isInstanceOf((Resource)content, type);\r
+    }\r
+    \r
+    \r
+}\r