1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.core
.event
.lookup
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.equalsNullable
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
20 * TMF call site information for source code lookup.
22 * @author Bernd Hufmann
24 public class TmfCallsite
implements ITmfCallsite
{
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 /** The file name string. */
31 private final @NonNull String fFileName
;
33 /** The function name. */
34 private final String fFunctionName
;
36 /** The line number. */
37 private final long fLineNumber
;
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * Default constructor.
53 public TmfCallsite(String fileName
, String functionName
, long lineNumber
) {
54 if (fileName
== null) {
55 throw new IllegalArgumentException();
58 fFunctionName
= functionName
;
59 fLineNumber
= lineNumber
;
66 * - An other call site implementation
68 public TmfCallsite(ITmfCallsite other
) {
70 throw new IllegalArgumentException();
72 fFileName
= other
.getFileName();
73 fFunctionName
= other
.getFunctionName();
74 fLineNumber
= other
.getLineNumber();
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 public @NonNull String
getFileName() {
87 public String
getFunctionName() {
92 public long getLineNumber() {
96 // ------------------------------------------------------------------------
98 // ------------------------------------------------------------------------
101 public int hashCode() {
102 final int prime
= 31;
104 // fFileName cannot be null!
105 result
= prime
* result
+ fFileName
.hashCode();
106 result
= prime
* result
+ ((fFunctionName
== null) ?
0 : fFunctionName
.hashCode());
107 result
= prime
* result
+ (int) (fLineNumber ^
(fLineNumber
>>> 32));
112 public boolean equals(Object obj
) {
119 if (getClass() != obj
.getClass()) {
122 TmfCallsite other
= (TmfCallsite
) obj
;
124 // fFileName cannot be null!
125 if (!fFileName
.equals(other
.fFileName
)) {
129 if (!equalsNullable(fFunctionName
, other
.fFunctionName
)) {
132 if (fLineNumber
!= other
.fLineNumber
) {
139 public String
toString() {
140 StringBuilder builder
= new StringBuilder();
141 builder
.append(fFileName
).append(':');
142 builder
.append(Long
.toString(fLineNumber
));
143 if (fFunctionName
!= null) {
145 builder
.append(fFunctionName
).append("()"); //$NON-NLS-1$
147 return builder
.toString();
This page took 0.046273 seconds and 5 git commands to generate.