tmf: Split the state system in a separate plugin
[deliverable/tracecompass.git] / org.eclipse.linuxtools.statesystem.core / src / org / eclipse / linuxtools / statesystem / core / statevalue / NullStateValue.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.statesystem.core.statevalue;
14
15 import org.eclipse.jdt.annotation.Nullable;
16
17 /**
18 * A state value that contains no particular value. It is sometimes needed over
19 * a "null" reference, since we avoid NPE's this way.
20 *
21 * It can also be read either as a String ("nullValue") or an Integer (-1).
22 *
23 * @version 1.0
24 * @author Alexandre Montplaisir
25 */
26 final class NullStateValue extends TmfStateValue {
27
28 private final String value = "nullValue"; //$NON-NLS-1$
29
30 @Override
31 public Type getType() {
32 return Type.NULL;
33 }
34
35 @Override
36 public boolean isNull() {
37 return true;
38 }
39
40 @Override
41 public boolean equals(@Nullable Object object) {
42 return (object instanceof NullStateValue);
43 }
44
45 @Override
46 public int hashCode() {
47 return 0;
48 }
49
50 @Override
51 public String toString() {
52 return value;
53 }
54
55 // ------------------------------------------------------------------------
56 // Unboxing methods. Null values can be unboxed into any type.
57 // ------------------------------------------------------------------------
58
59 @Override
60 public int unboxInt() {
61 return -1;
62 }
63
64 @Override
65 public long unboxLong() {
66 return -1;
67 }
68
69 @Override
70 public double unboxDouble() {
71 return Double.NaN;
72 }
73
74 @Override
75 public String unboxStr() {
76 return value;
77 }
78 }
This page took 0.032649 seconds and 5 git commands to generate.