]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/primitives/MutableInteger.java
Added addFirst/After/Before + remove SCL functions for Ordered Sets
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / primitives / MutableInteger.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 MutableInteger extends Number implements Comparable<MutableInteger> {
15
16         private static final long serialVersionUID = 1L;
17         
18         public int value;
19         
20         public MutableInteger() {}
21         
22         public MutableInteger(int value) { this.value = value; }
23         
24         public byte byteValue() {
25                 return (byte) value;
26         }
27
28         public short shortValue() {
29                 return (short) value;
30         }
31
32         public int intValue() {
33                 return value;
34         }
35
36         public long longValue() {
37                 return (long) value;
38         }
39
40         public float floatValue() {
41                 return (float) value;
42         }
43
44         public double doubleValue() {
45                 return (double) value;
46         }
47
48         public String toString() {
49                 return String.valueOf(value);
50         }
51
52         public int hashCode() {
53                 return value;
54         }
55
56         public boolean equals(Object obj) {
57                 if (obj == null) return false;
58                 if (obj == this) return true;
59
60                 if (obj instanceof MutableInteger) {
61                         return value == ((MutableInteger) obj).intValue();
62                 }
63                 return false;
64         }
65         
66     public int compareTo(MutableInteger anotherInteger) {
67         int thisVal = this.value;
68         int anotherVal = anotherInteger.value;
69         return (thisVal<anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1));
70     }
71     
72 }