]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/primitives/MutableByte.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / primitives / MutableByte.java
1 /*******************************************************************************\r
2  *  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.primitives;
13
14 public class MutableByte extends Number implements Comparable<MutableByte> {
15
16         private static final long serialVersionUID = 1L;
17         
18         public byte value;
19         
20         public MutableByte() {}
21         
22         public MutableByte(byte value) { this.value = value; }
23
24         @Override
25         public double doubleValue() {
26                 return value;
27         }
28
29         @Override
30         public float floatValue() {
31                 return value;
32         }
33
34         @Override
35         public int intValue() {
36                 return value;
37         }
38
39         @Override
40         public long longValue() {
41                 return value;
42         }
43         
44         public String toString() {
45                 return String.valueOf((int) value);
46         }
47
48         public int hashCode() {
49                 return (int) value;
50         }
51
52         public boolean equals(Object obj) {
53                 if (obj == null) return false;\r
54                 if (obj == this) return true;\r
55                 \r
56                 if (obj instanceof MutableByte) {
57                         return value == ((MutableByte) obj).byteValue();
58                 }
59                 return false;
60         }
61
62         public int compareTo(MutableByte anotherByte) {
63                 return this.value - anotherByte.value;
64         }       
65         
66 }
67