Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / event / lookup / TmfCallsite.java
CommitLineData
f47ed727 1/*******************************************************************************
ed902a2b 2 * Copyright (c) 2013, 2014 Ericsson
f47ed727
BH
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
2bdf0193 13package org.eclipse.tracecompass.tmf.core.event.lookup;
f47ed727 14
7709e228 15import static org.eclipse.tracecompass.common.core.NonNullUtils.equalsNullable;
f47ed727
BH
16
17/**
18 * TMF call site information for source code lookup.
19 *
f47ed727
BH
20 * @author Bernd Hufmann
21 */
22public class TmfCallsite implements ITmfCallsite {
23
24 // ------------------------------------------------------------------------
25 // Attributes
26 // ------------------------------------------------------------------------
27
28 /** The file name string. */
29 final private String fFileName;
30
31 /** The function name. */
32 final private String fFunctionName;
33
34 /** The line number. */
35 final private long fLineNumber;
36
37 // ------------------------------------------------------------------------
38 // Constructors
39 // ------------------------------------------------------------------------
40
41 /**
42 * Default constructor.
43 *
44 * @param fileName
45 * - a file name
46 * @param functionName
47 * - a function name
48 * @param lineNumber
49 * - a line number
50 */
51 public TmfCallsite(String fileName, String functionName, long lineNumber) {
52 if (fileName == null) {
53 throw new IllegalArgumentException();
54 }
55 fFileName = fileName;
56 fFunctionName = functionName;
57 fLineNumber = lineNumber;
58 }
59
60 /**
61 * Copy Constructor.
62 *
63 * @param other
64 * - An other call site implementation
65 */
66 public TmfCallsite(ITmfCallsite other) {
67 if ((other == null) || (other.getFileName() == null)) {
68 throw new IllegalArgumentException();
69 }
70 fFileName = other.getFileName();
71 fFunctionName = other.getFunctionName();
72 fLineNumber = other.getLineNumber();
73 }
74
75 // ------------------------------------------------------------------------
76 // Accessors
77 // ------------------------------------------------------------------------
78
79 @Override
80 public String getFileName() {
81 return fFileName;
82 }
83
84 @Override
85 public String getFunctionName() {
86 return fFunctionName;
87 }
88
89 @Override
90 public long getLineNumber() {
91 return fLineNumber;
92 }
93
94 // ------------------------------------------------------------------------
95 // Operations
96 // ------------------------------------------------------------------------
97
98 @Override
99 public int hashCode() {
100 final int prime = 31;
101 int result = 1;
7709e228
MK
102 // fFileName cannot be null!
103 result = prime * result + fFileName.hashCode();
f47ed727
BH
104 result = prime * result + ((fFunctionName == null) ? 0 : fFunctionName.hashCode());
105 result = prime * result + (int) (fLineNumber ^ (fLineNumber >>> 32));
106 return result;
107 }
108
109 @Override
110 public boolean equals(Object obj) {
111 if (this == obj) {
112 return true;
113 }
114 if (obj == null) {
115 return false;
116 }
117 if (getClass() != obj.getClass()) {
118 return false;
119 }
120 TmfCallsite other = (TmfCallsite) obj;
121
122 // fFileName cannot be null!
123 if (!fFileName.equals(other.fFileName)) {
124 return false;
125 }
126
7709e228 127 if (!equalsNullable(fFunctionName, other.fFunctionName)) {
f47ed727
BH
128 return false;
129 }
130 if (fLineNumber != other.fLineNumber) {
131 return false;
132 }
133 return true;
134 }
135
136 @Override
137 public String toString() {
138 StringBuilder builder = new StringBuilder();
139 builder.append(fFileName).append(':');
140 builder.append(Long.toString(fLineNumber));
141 if (fFunctionName != null) {
142 builder.append(' ');
143 builder.append(fFunctionName).append("()"); //$NON-NLS-1$
144 }
145 return builder.toString();
146 }
147}
This page took 0.071772 seconds and 5 git commands to generate.