]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/mutable/MutableBooleanBinding.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / mutable / MutableBooleanBinding.java
1 /*******************************************************************************\r
2 s *  Copyright (c) 2010 Association for Decentralized Information Management in\r
3  *  Industry THTH ry.\r
4  *  All rights reserved. This program and the accompanying materials\r
5  *  are made available under the terms of the Eclipse Public License v1.0\r
6  *  which accompanies this distribution, and is available at\r
7  *  http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  *  Contributors:\r
10  *      VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.databoard.binding.mutable;
13
14 import org.simantics.databoard.binding.BooleanBinding;\r
15 import org.simantics.databoard.binding.error.BindingException;\r
16 import org.simantics.databoard.primitives.MutableBoolean;\r
17 import org.simantics.databoard.type.BooleanType;\r
18
19 /**
20  * Binds BooleanType to {@link MutableBoolean}
21  *
22  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
23  */
24 public class MutableBooleanBinding extends BooleanBinding {
25         
26         public MutableBooleanBinding(BooleanType type) {
27                 super(type);
28         }
29
30         public Object create(boolean value) {
31                 MutableBoolean result = new MutableBoolean();
32                 result.value = value;
33                 return result;
34         }
35         
36         public Object create(Boolean value) {
37                 MutableBoolean result = new MutableBoolean();
38                 result.value = value;
39                 return result;
40         }
41         
42         @Override
43         public void setValue(Object obj, boolean newValue) throws BindingException {
44                 MutableBoolean result = (MutableBoolean) obj;
45                 result.value = newValue;
46         }
47         
48         @Override
49         public void setValue(Object obj, Boolean newValue) throws BindingException {
50                 MutableBoolean result = (MutableBoolean) obj;
51                 result.value = newValue;
52         }
53         
54         public Boolean getValue(Object o) {
55                 return ((MutableBoolean)o).value;
56         }
57         
58         @Override
59         public boolean getValue_(Object o) {
60                 return ((MutableBoolean)o).value;
61         }
62         
63     @Override
64         public boolean isInstance(Object obj) {
65                 return obj instanceof MutableBoolean;
66         }
67         
68         
69 }
70
71