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); } } }