1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.core
.trace
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
19 * A pair of trace location and trace rank.
22 * @author Patrick Tasse
24 public class TmfRankedLocation
implements Comparable
<TmfRankedLocation
>, Cloneable
{
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 private ITmfLocation
<?
extends Comparable
<?
>> fLocation
;
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
38 * The standard constructor
40 * @param context a trace context
42 public TmfRankedLocation(ITmfContext context
) {
43 fLocation
= context
.getLocation().clone();
44 fRank
= context
.getRank();
50 * @param location the trace location
51 * @param rank the trace rank
53 private TmfRankedLocation(ITmfLocation
<?
extends Comparable
<?
>> location
, long rank
) {
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
63 * Get the trace location
65 * @return the trace location
67 public ITmfLocation
<?
extends Comparable
<?
>> getLocation() {
74 * @return the trace rank
76 public long getRank() {
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 * @see java.lang.Object#clone()
88 public TmfRankedLocation
clone() {
89 return new TmfRankedLocation(fLocation
.clone(), fRank
);
92 // ------------------------------------------------------------------------
94 // ------------------------------------------------------------------------
98 * @see java.lang.Comparable#compareTo(java.lang.Object)
101 public int compareTo(TmfRankedLocation o
) {
102 return Long
.valueOf(fRank
).compareTo(Long
.valueOf(o
.fRank
));
105 // ------------------------------------------------------------------------
107 // ------------------------------------------------------------------------
110 * @see java.lang.Object#hashCode()
113 public int hashCode() {
114 final int prime
= 31;
116 result
= prime
* result
+ ((fLocation
== null) ?
0 : fLocation
.hashCode());
117 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
122 * @see java.lang.Object#equals(java.lang.Object)
125 public boolean equals(Object obj
) {
132 if (getClass() != obj
.getClass()) {
135 TmfRankedLocation other
= (TmfRankedLocation
) obj
;
136 if (fLocation
== null) {
137 if (other
.fLocation
!= null) {
140 } else if (!fLocation
.equals(other
.fLocation
)) {
143 if (fRank
!= other
.fRank
) {
150 * @see java.lang.Object#toString()
153 @SuppressWarnings("nls")
154 public String
toString() {
155 return fLocation
+ "," + fRank
;
This page took 0.032813 seconds and 5 git commands to generate.