]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/reflection/VoidBinding.java
Improved Bindings.getBinding(Class) caching for Datatype.class
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / reflection / VoidBinding.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
4  *  All rights reserved. This program and the accompanying materials
5  *  are made available under the terms of the Eclipse Public License v1.0
6  *  which accompanies this distribution, and is available at
7  *  http://www.eclipse.org/legal/epl-v10.html
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.binding.reflection;
13
14 import org.simantics.databoard.binding.Binding;
15 import org.simantics.databoard.binding.RecordBinding;
16 import org.simantics.databoard.binding.error.BindingException;
17 import org.simantics.databoard.type.Datatype;
18 import org.simantics.databoard.type.RecordType;
19
20 /**
21  * Binds void.class to {}
22  */
23 public class VoidBinding extends RecordBinding {
24                 
25         public static final Binding VOID_BINDING = new VoidBinding();
26         
27         public VoidBinding() {
28                 this.type = RecordType.VOID_TYPE;
29                 this.componentBindings = new Binding[0];
30         }
31         
32         @Override
33         public Object create(Object... value) throws BindingException {
34                 return null;
35         }
36
37         @Override
38         public Object getComponent(Object obj, int index)
39                         throws BindingException {
40                 throw new BindingException();
41         }
42
43         @Override
44         public Object createPartial() throws BindingException {
45                 return null;
46         }
47         
48         @Override
49         public void readFrom(Binding srcBinding, Object src, Object dst)
50                         throws BindingException {
51         }
52
53         @Override
54         public void setComponents(Object obj, Object... value)
55                         throws BindingException {
56                 if (value.length==0) return;
57                 throw new BindingException();
58         }
59         
60         @Override
61         public void setComponent(Object obj, int index, Object value)
62                         throws BindingException {
63                 throw new BindingException();
64         }
65
66         @Override
67         public boolean isInstance(Object obj) {
68                 return obj==null;
69         }
70
71         @Override
72         public void setType(Datatype type) {
73                 super.setType(type);
74         }
75         
76         @Override
77         public boolean isImmutable() {
78                 return true;
79         }
80 }
81