X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fvariable%2FValueAccessorWithBinding.java;h=f8c4be2ff4b1725008907d76b48175dc3392af06;hp=ece82e26d43fb80cfc63c8d8131e0651a5b6c73b;hb=3c2807a26920491016a1887d2c1a95609c082a19;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ValueAccessorWithBinding.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ValueAccessorWithBinding.java index ece82e26d..f8c4be2ff 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ValueAccessorWithBinding.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ValueAccessorWithBinding.java @@ -1,42 +1,42 @@ -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.WriteGraph; -import org.simantics.db.exception.DatabaseException; - -/** - * A default implementation of value accessor that has fixed binding. - */ -public abstract class ValueAccessorWithBinding implements ValueAccessor { - - public abstract Binding getBinding(); - - @Override - public Object getValue(ReadGraph graph, Variable context, Binding binding) - throws DatabaseException { - try { - return Bindings.adapt(getValue(graph, context), getBinding(), binding); - } catch (AdaptException e) { - throw new DatabaseException(e); - } - } - - @Override - public void setValue(WriteGraph graph, Variable context, Object value, - Binding binding) throws DatabaseException { - try { - setValue(graph, context, Bindings.adapt(value, binding, getBinding())); - } catch (AdaptException e) { - throw new DatabaseException(e); - } - } - - @Override - public Datatype getDatatype(ReadGraph graph, Variable context) throws DatabaseException { - return getBinding().type(); - } -} +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.WriteGraph; +import org.simantics.db.exception.DatabaseException; + +/** + * A default implementation of value accessor that has fixed binding. + */ +public abstract class ValueAccessorWithBinding implements ValueAccessor { + + public abstract Binding getBinding(); + + @Override + public Object getValue(ReadGraph graph, Variable context, Binding binding) + throws DatabaseException { + try { + return Bindings.adapt(getValue(graph, context), getBinding(), binding); + } catch (AdaptException e) { + throw new DatabaseException(e); + } + } + + @Override + public void setValue(WriteGraph graph, Variable context, Object value, + Binding binding) throws DatabaseException { + try { + setValue(graph, context, Bindings.adapt(value, binding, getBinding())); + } catch (AdaptException e) { + throw new DatabaseException(e); + } + } + + @Override + public Datatype getDatatype(ReadGraph graph, Variable context) throws DatabaseException { + return getBinding().type(); + } +}