tmf: Re-add null annotations to tmf.core.statevalue
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / statevalue / IntegerStateValue.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
3 * Copyright (c) 2010, 2011 École Polytechnique de Montréal
4 * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com>
5 *
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
10 *
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.core.statevalue;
14
15 import org.eclipse.jdt.annotation.Nullable;
16
17 /**
18 * A state value containing a simple integer.
19 *
20 * @version 1.0
21 * @author Alexandre Montplaisir
22 */
23 final class IntegerStateValue extends TmfStateValue {
24
25 private final Integer valueInt;
26
27 public IntegerStateValue(int valueAsInt) {
28 this.valueInt = new Integer(valueAsInt);
29 }
30
31 @Override
32 public Type getType() {
33 return Type.INTEGER;
34 }
35
36 @Override
37 public boolean isNull() {
38 return false;
39 }
40
41 @Override
42 public Integer getValue() {
43 return valueInt;
44 }
45
46 @Override
47 public @Nullable String toString() {
48 return String.format("%3d", valueInt); //$NON-NLS-1$
49 }
50
51 // ------------------------------------------------------------------------
52 // Unboxing methods
53 // ------------------------------------------------------------------------
54
55 @Override
56 public int unboxInt() {
57 return valueInt;
58 }
59
60 @Override
61 public long unboxLong() {
62 /* It's always safe to up-cast a int into a long */
63 return valueInt;
64 }
65 }
This page took 0.031314 seconds and 5 git commands to generate.