]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/reflection/VoidBinding.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / reflection / VoidBinding.java
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 (file)
index 0000000..3523aaa
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************\r
+ *  Copyright (c) 2010 Association for Decentralized Information Management in\r
+ *  Industry THTH ry.\r
+ *  All rights reserved. This program and the accompanying materials\r
+ *  are made available under the terms of the Eclipse Public License v1.0\r
+ *  which accompanies this distribution, and is available at\r
+ *  http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ *  Contributors:\r
+ *      VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.databoard.binding.reflection;
+
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.binding.RecordBinding;\r
+import org.simantics.databoard.binding.error.BindingException;\r
+import org.simantics.databoard.type.Datatype;\r
+import org.simantics.databoard.type.RecordType;\r
+
+/**
+ * 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;
+       }\r
+       \r
+       @Override\r
+       public void readFrom(Binding srcBinding, Object src, Object dst)\r
+                       throws BindingException {\r
+       }
+
+       @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;
+       }
+}
+