tmf: remove deprecated methods from tmf
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / event / lookup / TmfCallsite.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.core.event.lookup;
14
15 import java.util.Objects;
16
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21 * TMF call site information for source code lookup.
22 *
23 * @author Bernd Hufmann
24 */
25 public class TmfCallsite implements ITmfCallsite {
26
27 // ------------------------------------------------------------------------
28 // Attributes
29 // ------------------------------------------------------------------------
30
31 /** The file name string. */
32 private final @NonNull String fFileName;
33
34 /** The line number. */
35 private final @Nullable Long fLineNumber;
36
37 // ------------------------------------------------------------------------
38 // Constructors
39 // ------------------------------------------------------------------------
40
41 /**
42 * Constructor
43 *
44 * @param fileName
45 * The source file's name
46 * @param lineNumber
47 * The line number in the source file
48 * @since 2.1
49 */
50 public TmfCallsite(@NonNull String fileName, @Nullable Long lineNumber) {
51 fFileName = fileName;
52 fLineNumber = lineNumber;
53 }
54
55 /**
56 * Copy Constructor.
57 *
58 * @param other
59 * - An other call site implementation
60 */
61 public TmfCallsite(@NonNull ITmfCallsite other) {
62 fFileName = other.getFileName();
63 fLineNumber = other.getLineNo();
64 }
65
66 // ------------------------------------------------------------------------
67 // Accessors
68 // ------------------------------------------------------------------------
69
70 @Override
71 public @NonNull String getFileName() {
72 return fFileName;
73 }
74
75 /**
76 * @since 2.1
77 */
78 @Override
79 public @Nullable Long getLineNo() {
80 return fLineNumber;
81 }
82
83 // ------------------------------------------------------------------------
84 // Operations
85 // ------------------------------------------------------------------------
86
87 @Override
88 public int hashCode() {
89 return Objects.hash(fFileName, fLineNumber);
90 }
91
92 @Override
93 public boolean equals(Object obj) {
94 if (this == obj) {
95 return true;
96 }
97 if (obj == null) {
98 return false;
99 }
100 if (getClass() != obj.getClass()) {
101 return false;
102 }
103 TmfCallsite other = (TmfCallsite) obj;
104
105 // fFileName cannot be null!
106 if (!fFileName.equals(other.fFileName)) {
107 return false;
108 }
109
110 if (fLineNumber != other.fLineNumber) {
111 return false;
112 }
113 return true;
114 }
115
116 @Override
117 public String toString() {
118 Long lineNumber = fLineNumber;
119
120 StringBuilder builder = new StringBuilder();
121 builder.append(fFileName).append(':');
122 builder.append(lineNumber == null ? "??" : Long.toString(lineNumber)); //$NON-NLS-1$
123 return builder.toString();
124 }
125 }
This page took 0.032965 seconds and 5 git commands to generate.