1 | /******************************************************************************* |
2 | * Copyright (c) 2008, 2009 IBM Corporation and others. |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 |
5 | * which accompanies this distribution, and is available at |
6 | * http://www.eclipse.org/legal/epl-v10.html |
7 | * |
8 | * Contributors: |
9 | * IBM Corporation - initial API and implementation |
10 | *******************************************************************************/ |
11 | package org.eclipse.pde.api.tools.internal.model; |
12 | |
13 | |
14 | /** |
15 | * A key for a method - name & signature based. |
16 | * |
17 | * @since 1.1 |
18 | */ |
19 | public class MethodKey { |
20 | private String fSelector; |
21 | private String fSig; |
22 | /** |
23 | * Constructs a new method key |
24 | * @param name method name |
25 | * @param sig method signature |
26 | */ |
27 | public MethodKey(String name, String sig) { |
28 | fSelector = name; |
29 | fSig = sig; |
30 | } |
31 | /* (non-Javadoc) |
32 | * @see java.lang.Object#equals(java.lang.Object) |
33 | */ |
34 | public boolean equals(Object obj) { |
35 | if (obj instanceof MethodKey) { |
36 | MethodKey key = (MethodKey) obj; |
37 | return fSelector.equals(key.fSelector) && |
38 | fSig.equals(key.fSig); |
39 | } |
40 | return false; |
41 | } |
42 | /* (non-Javadoc) |
43 | * @see java.lang.Object#hashCode() |
44 | */ |
45 | public int hashCode() { |
46 | return fSelector.hashCode() + fSig.hashCode(); |
47 | } |
48 | |
49 | /* (non-Javadoc) |
50 | * @see java.lang.Object#toString() |
51 | */ |
52 | public String toString() { |
53 | StringBuffer buf = new StringBuffer(); |
54 | buf.append(fSelector); |
55 | buf.append(fSig); |
56 | return buf.toString(); |
57 | } |
58 | } |