Commit | Line | Data |
---|---|---|
a52fde77 | 1 | /******************************************************************************* |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
a52fde77 AM |
3 | * Copyright (c) 2010, 2011 École Polytechnique de Montréal |
4 | * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com> | |
2cb26548 | 5 | * |
a52fde77 AM |
6 | * All rights reserved. This program and the accompanying materials are |
7 | * made available under the terms of the Eclipse Public License v1.0 which | |
8 | * accompanies this distribution, and is available at | |
9 | * http://www.eclipse.org/legal/epl-v10.html | |
2cb26548 | 10 | * |
a52fde77 AM |
11 | *******************************************************************************/ |
12 | ||
bcec0116 | 13 | package org.eclipse.linuxtools.statesystem.core.statevalue; |
a52fde77 | 14 | |
77c2c2c9 AM |
15 | import org.eclipse.jdt.annotation.Nullable; |
16 | ||
a52fde77 AM |
17 | /** |
18 | * A state value containing a simple integer. | |
a52fde77 | 19 | * |
2cb26548 AM |
20 | * @version 1.0 |
21 | * @author Alexandre Montplaisir | |
a52fde77 AM |
22 | */ |
23 | final class IntegerStateValue extends TmfStateValue { | |
24 | ||
6f7e27a0 | 25 | private final int value; |
a52fde77 AM |
26 | |
27 | public IntegerStateValue(int valueAsInt) { | |
6f7e27a0 | 28 | this.value = valueAsInt; |
a52fde77 AM |
29 | } |
30 | ||
31 | @Override | |
b67a2540 AM |
32 | public Type getType() { |
33 | return Type.INTEGER; | |
a52fde77 AM |
34 | } |
35 | ||
36 | @Override | |
37 | public boolean isNull() { | |
38 | return false; | |
39 | } | |
40 | ||
41 | @Override | |
6f7e27a0 EB |
42 | public boolean equals(@Nullable Object object) { |
43 | if (!(object instanceof IntegerStateValue)) { | |
44 | return false; | |
45 | } | |
46 | IntegerStateValue other = (IntegerStateValue) object; | |
47 | return (this.value == other.value); | |
48 | } | |
49 | ||
50 | @Override | |
51 | public int hashCode() { | |
52 | return value; | |
a52fde77 AM |
53 | } |
54 | ||
a52fde77 | 55 | @Override |
77c2c2c9 | 56 | public @Nullable String toString() { |
6f7e27a0 | 57 | return String.format("%3d", value); //$NON-NLS-1$ |
a52fde77 | 58 | } |
a9cdbafc AM |
59 | |
60 | // ------------------------------------------------------------------------ | |
61 | // Unboxing methods | |
62 | // ------------------------------------------------------------------------ | |
63 | ||
64 | @Override | |
65 | public int unboxInt() { | |
6f7e27a0 | 66 | return value; |
a9cdbafc AM |
67 | } |
68 | ||
69 | @Override | |
70 | public long unboxLong() { | |
359eeba0 | 71 | /* It's always safe to up-cast an int into a long */ |
6f7e27a0 | 72 | return value; |
a9cdbafc | 73 | } |
a52fde77 | 74 | } |