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