]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/primitives/MutableBoolean.java
Added addFirst/After/Before + remove SCL functions for Ordered Sets
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / primitives / MutableBoolean.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.primitives;
13
14 public class MutableBoolean implements Comparable<MutableBoolean> {
15
16         public boolean value;
17         
18         public MutableBoolean() {}
19         
20         public MutableBoolean(boolean value) { this.value = value; }
21         
22         public boolean getValue() {
23                 return value;
24         }
25         
26         public void setValue(boolean newValue) {
27                 this.value = newValue;
28         }
29
30     public boolean booleanValue() {
31         return value;
32     }   
33         
34     public int compareTo(MutableBoolean b) {
35         return (b.value == value ? 0 : (value ? 1 : -1));
36     }
37     
38     public int hashCode() {
39         return value ? 1231 : 1237;
40     }
41
42     public boolean equals(Object obj) {
43                 if (obj == null) return false;
44                 if (obj == this) return true;
45                 
46         if (obj instanceof MutableBoolean) {
47             return value == ((MutableBoolean)obj).booleanValue();
48         } 
49         return false;
50     }    
51     
52     @Override
53     public String toString() {
54         return value ? "true" : "false";
55     }
56     
57 }
58