X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fsrc%2Forg%2Fsimantics%2Fdataboard%2Fbinding%2Freflection%2FVoidBinding.java;fp=bundles%2Forg.simantics.databoard%2Fsrc%2Forg%2Fsimantics%2Fdataboard%2Fbinding%2Freflection%2FVoidBinding.java;h=3523aaa74e87ff7d4172f82c15112ec3b5148a0b;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/reflection/VoidBinding.java b/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/reflection/VoidBinding.java new file mode 100644 index 000000000..3523aaa74 --- /dev/null +++ b/bundles/org.simantics.databoard/src/org/simantics/databoard/binding/reflection/VoidBinding.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2010 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.databoard.binding.reflection; + +import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.binding.RecordBinding; +import org.simantics.databoard.binding.error.BindingException; +import org.simantics.databoard.type.Datatype; +import org.simantics.databoard.type.RecordType; + +/** + * Binds void.class to {} + */ +public class VoidBinding extends RecordBinding { + + public static final Binding VOID_BINDING = new VoidBinding(); + + public VoidBinding() { + this.type = RecordType.VOID_TYPE; + this.componentBindings = new Binding[0]; + } + + @Override + public Object create(Object... value) throws BindingException { + return null; + } + + @Override + public Object getComponent(Object obj, int index) + throws BindingException { + throw new BindingException(); + } + + @Override + public Object createPartial() throws BindingException { + return null; + } + + @Override + public void readFrom(Binding srcBinding, Object src, Object dst) + throws BindingException { + } + + @Override + public void setComponents(Object obj, Object... value) + throws BindingException { + if (value.length==0) return; + throw new BindingException(); + } + + @Override + public void setComponent(Object obj, int index, Object value) + throws BindingException { + throw new BindingException(); + } + + @Override + public boolean isInstance(Object obj) { + return obj==null; + } + + @Override + public void setType(Datatype type) { + super.setType(type); + } + + @Override + public boolean isImmutable() { + return true; + } +} +