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