Merge branch 'master' into lttng-kepler
[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
36 /**
37 * Default constructor (for the 'null' location)
38 */
2848c377 39 @SuppressWarnings("unused")
fcccd900 40 private TmfLocation() {
577ee847 41 fLocationInfo = null;
fcccd900
FC
42 }
43
44 /**
45 * Standard constructor.
0283f7ff 46 *
5976d44a 47 * @param locationInfo the concrete trace location
fcccd900 48 */
5976d44a
FC
49 public TmfLocation(final Comparable<?> locationInfo) {
50 fLocationInfo = locationInfo;
fcccd900
FC
51 }
52
53 /**
54 * Copy constructor
0283f7ff 55 *
5976d44a 56 * @param location the original trace location
fcccd900 57 */
1e1bef82 58 public TmfLocation(final TmfLocation location) {
5976d44a 59 fLocationInfo = location.fLocationInfo;
fcccd900
FC
60 }
61
62 // ------------------------------------------------------------------------
63 // Getters
64 // ------------------------------------------------------------------------
65
5976d44a
FC
66 /* (non-Javadoc)
67 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationInfo()
68 */
6bab4511
AM
69 /**
70 * @since 2.0
fcccd900
FC
71 */
72 @Override
5976d44a
FC
73 public Comparable<?> getLocationInfo() {
74 return fLocationInfo;
fcccd900
FC
75 }
76
fcccd900 77 // ------------------------------------------------------------------------
ff4ed569
FC
78 // Object
79 // ------------------------------------------------------------------------
80
fcccd900
FC
81 /* (non-Javadoc)
82 * @see java.lang.Object#hashCode()
83 */
84 @Override
ff4ed569 85 public int hashCode() {
fcccd900
FC
86 final int prime = 31;
87 int result = 1;
5976d44a 88 result = prime * result + ((fLocationInfo != null) ? fLocationInfo.hashCode() : 0);
fcccd900 89 return result;
ff4ed569
FC
90 }
91
fcccd900
FC
92 /* (non-Javadoc)
93 * @see java.lang.Object#equals(java.lang.Object)
94 */
ff4ed569 95 @Override
5d837f9b 96 public boolean equals(final Object obj) {
0316808c 97 if (this == obj) {
fcccd900 98 return true;
0316808c
FC
99 }
100 if (obj == null) {
fcccd900 101 return false;
0316808c
FC
102 }
103 if (getClass() != obj.getClass()) {
fcccd900 104 return false;
0316808c 105 }
1e1bef82 106 final TmfLocation other = (TmfLocation) obj;
5976d44a
FC
107 if (fLocationInfo == null) {
108 if (other.fLocationInfo != null) {
fcccd900 109 return false;
0316808c 110 }
5976d44a 111 } else if (!fLocationInfo.equals(other.fLocationInfo)) {
fcccd900 112 return false;
0316808c 113 }
fcccd900 114 return true;
ff4ed569
FC
115 }
116
fcccd900 117 @Override
cbdacf03 118 @SuppressWarnings("nls")
fcccd900 119 public String toString() {
5976d44a 120 return "TmfLocation [fLocation=" + fLocationInfo + "]";
fcccd900 121 }
452ad365 122
8c8bf09f 123}
This page took 0.044296 seconds and 5 git commands to generate.