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