1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 École Polytechnique de Montréal
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
10 * François Rajotte - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.StateValueTypeException
;
19 * A state value containing a long integer (8 bytes).
22 * @author François Rajotte
24 final class LongStateValue
extends TmfStateValue
{
26 private final long value
;
28 public LongStateValue(long valueAsLong
) {
29 this.value
= valueAsLong
;
33 public Type
getType() {
38 public boolean isNull() {
43 public boolean equals(@Nullable Object object
) {
44 if (!(object
instanceof LongStateValue
)) {
47 LongStateValue other
= (LongStateValue
) object
;
48 return (this.value
== other
.value
);
52 public int hashCode() {
53 return ((int) value
) ^
((int) (value
>>> 32));
57 public @Nullable String
toString() {
58 return String
.format("%3d", value
); //$NON-NLS-1$
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
66 public long unboxLong() {
71 public int compareTo(@Nullable ITmfStateValue other
) {
73 throw new IllegalArgumentException();
76 switch (other
.getType()) {
78 long otherLongValue
= ((IntegerStateValue
) other
).unboxInt();
79 return Long
.compare(this.value
, otherLongValue
);
81 double otherDoubleValue
= ((DoubleStateValue
) other
).unboxDouble();
82 return Double
.compare(this.value
, otherDoubleValue
);
84 otherLongValue
= ((LongStateValue
) other
).unboxLong();
85 return Long
.compare(this.value
, otherLongValue
);
87 return Long
.compare(this.value
, other
.unboxLong());
89 throw new StateValueTypeException("A Long state value cannot be compared to a String state value."); //$NON-NLS-1$
91 throw new StateValueTypeException("A Long state value cannot be compared to the type " + other
.getType()); //$NON-NLS-1$
This page took 0.033784 seconds and 6 git commands to generate.