]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/ge/VariableInstanceOfTest.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.document.linking.ui / src / org / simantics / document / linking / ge / VariableInstanceOfTest.java
1 package org.simantics.document.linking.ge;
2
3 import org.simantics.browsing.ui.model.tests.Test;
4 import org.simantics.db.ReadGraph;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.layer0.variable.Variable;
8
9 public class VariableInstanceOfTest  implements Test  {
10         Resource type;
11         
12         public VariableInstanceOfTest(Resource type) {
13                 this.type = type;
14         }
15         
16         
17         @Override
18         public boolean isCompatible(Class<?> contentType) {
19                 return contentType == Variable.class;
20         }
21         
22         @Override
23         public boolean test(ReadGraph graph, Object content)
24                         throws DatabaseException {
25                 Variable variable = (Variable)content;
26                 Resource res = variable.getPossibleRepresents(graph);
27                 if (res == null)
28                         return false;
29                 return graph.isInstanceOf(res, type);
30         }
31         
32
33 }