tmf: Make CtfLocation extend TmfLocation
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / trace / TmfLocation.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010, 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.core.trace;
15
16
17 /**
18 * A abstract implementation of ITmfLocation. The concrete classes must provide
19 * comparable location information.
20 *
21 * @version 2.0
22 * @author Francois Chouinard
23 */
24 public abstract class TmfLocation implements ITmfLocation {
25
26 // ------------------------------------------------------------------------
27 // Attributes
28 // ------------------------------------------------------------------------
29
30 private final Comparable<?> fLocationInfo;
31
32 // ------------------------------------------------------------------------
33 // Constructors
34 // ------------------------------------------------------------------------
35
36 /**
37 * Standard constructor.
38 *
39 * @param locationInfo
40 * The concrete trace location
41 */
42 public TmfLocation(final Comparable<?> locationInfo) {
43 fLocationInfo = locationInfo;
44 }
45
46 /**
47 * Copy constructor
48 *
49 * @param location
50 * The original trace location
51 */
52 public TmfLocation(final TmfLocation location) {
53 fLocationInfo = location.fLocationInfo;
54 }
55
56 // ------------------------------------------------------------------------
57 // Getters
58 // ------------------------------------------------------------------------
59
60 /**
61 * @since 2.0
62 */
63 @Override
64 public Comparable<?> getLocationInfo() {
65 return fLocationInfo;
66 }
67
68 // ------------------------------------------------------------------------
69 // Object
70 // ------------------------------------------------------------------------
71
72 @Override
73 public int hashCode() {
74 final int prime = 31;
75 int result = 1;
76 result = prime * result + ((fLocationInfo != null) ? fLocationInfo.hashCode() : 0);
77 return result;
78 }
79
80 @Override
81 public boolean equals(final Object obj) {
82 if (this == obj) {
83 return true;
84 }
85 if (obj == null) {
86 return false;
87 }
88 if (getClass() != obj.getClass()) {
89 return false;
90 }
91 final TmfLocation other = (TmfLocation) obj;
92 if (fLocationInfo == null) {
93 if (other.fLocationInfo != null) {
94 return false;
95 }
96 } else if (!fLocationInfo.equals(other.fLocationInfo)) {
97 return false;
98 }
99 return true;
100 }
101
102 @Override
103 @SuppressWarnings("nls")
104 public String toString() {
105 return getClass().getSimpleName() + " [fLocationInfo=" + fLocationInfo.toString() + "]";
106 }
107
108 }
This page took 0.034555 seconds and 5 git commands to generate.