Commit | Line | Data |
---|---|---|
1cbf1a19 FR |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 École Polytechnique de Montréal | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | ||
9 | * Contributors: | |
10 | * François Rajotte - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.core.statevalue; | |
14 | ||
77c2c2c9 AM |
15 | import org.eclipse.jdt.annotation.Nullable; |
16 | ||
1cbf1a19 FR |
17 | /** |
18 | * A state value containing a long integer (8 bytes). | |
19 | * | |
20 | * @version 1.0 | |
21 | * @author François Rajotte | |
22 | */ | |
23 | final class LongStateValue extends TmfStateValue { | |
24 | ||
6f7e27a0 | 25 | private final long value; |
1cbf1a19 FR |
26 | |
27 | public LongStateValue(long valueAsLong) { | |
6f7e27a0 | 28 | this.value = valueAsLong; |
1cbf1a19 FR |
29 | } |
30 | ||
31 | @Override | |
32 | public Type getType() { | |
33 | return Type.LONG; | |
34 | } | |
35 | ||
36 | @Override | |
37 | public boolean isNull() { | |
38 | return false; | |
39 | } | |
6f7e27a0 EB |
40 | @Override |
41 | public boolean equals(@Nullable Object object) { | |
42 | if (!(object instanceof LongStateValue)) { | |
43 | return false; | |
44 | } | |
45 | LongStateValue other = (LongStateValue) object; | |
46 | return (this.value == other.value); | |
47 | } | |
1cbf1a19 FR |
48 | |
49 | @Override | |
6f7e27a0 EB |
50 | public int hashCode() { |
51 | return ((int) value) ^ ((int) (value >>> 32)); | |
1cbf1a19 FR |
52 | } |
53 | ||
1cbf1a19 | 54 | @Override |
77c2c2c9 | 55 | public @Nullable String toString() { |
6f7e27a0 | 56 | return String.format("%3d", value); //$NON-NLS-1$ |
1cbf1a19 | 57 | } |
a9cdbafc AM |
58 | |
59 | // ------------------------------------------------------------------------ | |
60 | // Unboxing methods | |
61 | // ------------------------------------------------------------------------ | |
62 | ||
63 | @Override | |
64 | public long unboxLong() { | |
6f7e27a0 | 65 | return value; |
a9cdbafc | 66 | } |
1cbf1a19 | 67 | } |