]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/ReflectionExternalValue.java
Multiple readers and variable optimization
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / adapter / ReflectionExternalValue.java
1 package org.simantics.db.layer0.adapter;
2
3 import org.simantics.db.ExternalValue;
4 import org.simantics.db.ReadGraph;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.scl.reflection.ReflectionUtils;
8 import org.simantics.scl.reflection.ValueNotFoundException;
9
10 public class ReflectionExternalValue implements ExternalValue {
11
12         @Override
13         public <T> T getValue(ReadGraph graph, Resource resource) throws DatabaseException {
14                 
15                 try {
16                         return (T)ReflectionUtils.getValue(graph.getURI(resource)).getValue();
17                 } catch(ValueNotFoundException e) {
18                         throw new DatabaseException(e);
19                 } catch(ClassCastException e) {
20                         throw new DatabaseException(e);
21                 }
22                 
23         }
24
25 }