01: /*
02: * FindBugs - Find Bugs in Java programs
03: * Copyright (C) 2005, University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19:
20: package edu.umd.cs.findbugs.ba;
21:
22: /**
23: * @author pugh
24: */
25: public class XMethodParameter implements Comparable<XMethodParameter> {
26: /**
27: * Create a new Method parameter reference
28: * @param m the method of which this is a parameter to
29: * @param p the parameter index (0 for first parameter)
30: */
31: public XMethodParameter(XMethod m, int p) {
32: method = m;
33: parameter = p;
34: }
35:
36: private final XMethod method;
37: private final int parameter;
38:
39: public XMethod getMethod() {
40: return method;
41: }
42:
43: public int getParameterNumber() {
44: return parameter;
45: }
46:
47: @Override
48: public boolean equals(Object o) {
49: if (!(o instanceof XMethodParameter))
50: return false;
51: XMethodParameter mp2 = (XMethodParameter) o;
52: return parameter == mp2.parameter && method.equals(mp2.method);
53: }
54:
55: @Override
56: public int hashCode() {
57: return method.hashCode() + parameter;
58: }
59:
60: public int compareTo(XMethodParameter mp2) {
61: int result = method.compareTo(mp2.method);
62: if (result != 0)
63: return result;
64: return parameter - mp2.parameter;
65: }
66:
67: @Override
68: public String toString() {
69: return "parameter " + parameter + " of " + method;
70: }
71: }
|