tmf: Rename CtfLocationData to CtfLocationInfo
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfLocationInfo.java
1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * 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: Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
12
13 /**
14 * The data object to go in a {@link CtfLocation}.
15 *
16 * @author Matthew Khouzam
17 * @since 2.0
18 */
19 public class CtfLocationInfo implements Comparable<CtfLocationInfo> {
20
21 private final long timestamp;
22 private final long index;
23
24 /**
25 * @param ts
26 * Timestamp
27 * @param index
28 * Index of this event (if there are N elements with the same
29 * timestamp, which one is it.)
30 */
31 public CtfLocationInfo(long ts, long index) {
32 this.timestamp = ts;
33 this.index = index;
34 }
35
36 /**
37 * @return The timestamp
38 */
39 public long getTimestamp() {
40 return timestamp;
41 }
42
43 /**
44 * @return The index of the element
45 */
46 public long getIndex() {
47 return index;
48 }
49
50 // ------------------------------------------------------------------------
51 // Object
52 // ------------------------------------------------------------------------
53
54 @Override
55 public int hashCode() {
56 final int prime = 31;
57 int result = 1;
58 result = (prime * result) + (int) (index ^ (index >>> 32));
59 result = (prime * result) + (int) (timestamp ^ (timestamp >>> 32));
60 return result;
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj) {
66 return true;
67 }
68 if (obj == null) {
69 return false;
70 }
71 if (!(obj instanceof CtfLocationInfo)) {
72 return false;
73 }
74 CtfLocationInfo other = (CtfLocationInfo) obj;
75 if (index != other.index) {
76 return false;
77 }
78 if (timestamp != other.timestamp) {
79 return false;
80 }
81 return true;
82 }
83
84 @Override
85 public String toString() {
86 return "Element [" + timestamp + '/' + index + ']'; //$NON-NLS-1$
87 }
88
89 // ------------------------------------------------------------------------
90 // Comparable
91 // ------------------------------------------------------------------------
92
93 @Override
94 public int compareTo(CtfLocationInfo other) {
95 if (this.timestamp > other.getTimestamp()) {
96 return 1;
97 }
98 if (this.timestamp < other.getTimestamp()) {
99 return -1;
100 }
101 if (this.index > other.getIndex()) {
102 return 1;
103 }
104 if (this.index < other.getIndex()) {
105 return -1;
106 }
107 return 0;
108 }
109
110 }
This page took 0.032287 seconds and 5 git commands to generate.