X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fadapter%2FReflectionExternalValue.java;fp=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fadapter%2FReflectionExternalValue.java;h=6bc6afb3bbc6d0a7990068adac0412c86d485037;hb=3850fec72035293b9a4ede780d01aedc5fbc9056;hp=0000000000000000000000000000000000000000;hpb=1e957fc9da518f3bef8a2c19cad72772087e1b6a;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/ReflectionExternalValue.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/ReflectionExternalValue.java new file mode 100644 index 000000000..6bc6afb3b --- /dev/null +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/adapter/ReflectionExternalValue.java @@ -0,0 +1,25 @@ +package org.simantics.db.layer0.adapter; + +import org.simantics.db.ExternalValue; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.scl.reflection.ReflectionUtils; +import org.simantics.scl.reflection.ValueNotFoundException; + +public class ReflectionExternalValue implements ExternalValue { + + @Override + public T getValue(ReadGraph graph, Resource resource) throws DatabaseException { + + try { + return (T)ReflectionUtils.getValue(graph.getURI(resource)).getValue(); + } catch(ValueNotFoundException e) { + throw new DatabaseException(e); + } catch(ClassCastException e) { + throw new DatabaseException(e); + } + + } + +}