]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/impl/BooleanBindingDefault.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / impl / BooleanBindingDefault.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.impl;
13
14 import org.simantics.databoard.binding.BooleanBinding;
15 import org.simantics.databoard.binding.error.BindingException;
16 import org.simantics.databoard.binding.error.UnsupportedOperationException;
17 import org.simantics.databoard.type.BooleanType;
18
19 /**
20  * Binds Boolean Type to java.lang.Boolean-class. 
21  *
22  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
23  */
24 public class BooleanBindingDefault extends BooleanBinding {
25
26         public BooleanBindingDefault(BooleanType type) {
27                 super( type );
28         }
29
30         public Object create(boolean value) 
31         {
32                 return value;
33         }
34         
35         public Object create(Boolean value) 
36         {
37                 return value;
38         }
39
40         public void setValue(Object obj, Boolean newValue) 
41         throws BindingException
42         {
43                 throw new UnsupportedOperationException("Cannot change the value of immutable java.lang.Boolean");
44         }
45         
46         public void setValue(Object obj, boolean newValue) 
47         throws BindingException
48         {
49                 if (((Boolean)obj).booleanValue() == newValue) return;
50                 throw new UnsupportedOperationException("Cannot change the value of immutable java.lang.Boolean");
51         }
52
53         @Override
54         public Boolean getValue(Object o) 
55         throws BindingException
56         {
57                 return ((Boolean)o);
58         }
59         
60         @Override
61         public boolean getValue_(Object o) 
62         throws BindingException
63         {
64                 return ((Boolean)o);
65         }
66
67     @Override
68         public boolean isInstance(Object obj) {
69                 return obj instanceof Boolean;
70         }
71     
72     @Override
73     public boolean isImmutable() {
74         return true;
75     }
76         
77 }
78