X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fvariable%2FConstantValueStandardGraphPropertyVariable.java;h=776ba588eb220f7775b804e0cd51b6719fa7a04c;hb=15af8a20abe8b2ba24b52c9da8bce6c92351dc43;hp=3b063f1a44caa940d39f83410cc599d064d4fcdb;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantValueStandardGraphPropertyVariable.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantValueStandardGraphPropertyVariable.java index 3b063f1a4..776ba588e 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantValueStandardGraphPropertyVariable.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ConstantValueStandardGraphPropertyVariable.java @@ -1,54 +1,54 @@ -package org.simantics.db.layer0.variable; - -import org.simantics.databoard.Bindings; -import org.simantics.databoard.adapter.AdaptException; -import org.simantics.databoard.binding.Binding; -import org.simantics.databoard.type.Datatype; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.exception.DatabaseException; - -public class ConstantValueStandardGraphPropertyVariable extends StandardGraphPropertyVariable { - - final private Object value; - final private Datatype datatype; - - public ConstantValueStandardGraphPropertyVariable(ReadGraph graph, Variable parent, Resource parentResource, Resource predicate, Object value, Datatype datatype) throws DatabaseException { - super(graph, parent, null, parentResource, predicate); - this.value = value; - this.datatype = datatype; - } - - @SuppressWarnings("unchecked") - @Override - public T getValue(ReadGraph graph) throws DatabaseException { - return (T)value; - } - - @SuppressWarnings("unchecked") - @Override - public T getValue(ReadGraph graph, Binding binding) throws DatabaseException { - try { - return (T)Bindings.adapt(value, Bindings.getBinding(datatype), binding); - } catch (AdaptException e) { - throw new DatabaseException(e); - } - } - - @Override - public Datatype getDatatype(ReadGraph graph) throws DatabaseException { - return datatype; - } - - @Override - public void setValue(WriteGraph graph, Object value) throws DatabaseException { - throw new DatabaseException("setValue is not supported."); - } - - @Override - public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException { - throw new DatabaseException("setValue is not supported."); - } - -} +package org.simantics.db.layer0.variable; + +import org.simantics.databoard.Bindings; +import org.simantics.databoard.adapter.AdaptException; +import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.type.Datatype; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.exception.DatabaseException; + +public class ConstantValueStandardGraphPropertyVariable extends StandardGraphPropertyVariable { + + final private Object value; + final private Datatype datatype; + + public ConstantValueStandardGraphPropertyVariable(ReadGraph graph, Variable parent, Resource parentResource, Resource predicate, Object value, Datatype datatype) throws DatabaseException { + super(graph, parent, null, parentResource, predicate); + this.value = value; + this.datatype = datatype; + } + + @SuppressWarnings("unchecked") + @Override + public T getValue(ReadGraph graph) throws DatabaseException { + return (T)value; + } + + @SuppressWarnings("unchecked") + @Override + public T getValue(ReadGraph graph, Binding binding) throws DatabaseException { + try { + return (T)Bindings.adapt(value, Bindings.getBinding(datatype), binding); + } catch (AdaptException e) { + throw new DatabaseException(e); + } + } + + @Override + public Datatype getDatatype(ReadGraph graph) throws DatabaseException { + return datatype; + } + + @Override + public void setValue(WriteGraph graph, Object value) throws DatabaseException { + throw new DatabaseException("setValue is not supported."); + } + + @Override + public void setValue(WriteGraph graph, Object value, Binding binding) throws DatabaseException { + throw new DatabaseException("setValue is not supported."); + } + +}