| 1 | |
package com.thoughtworks.qdox.parser.structs; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.HashSet; |
| 5 | |
import java.util.List; |
| 6 | |
import java.util.Set; |
| 7 | |
|
| 8 | 1993 | public class MethodDef extends LocatedDef { |
| 9 | 1993 | public String name = ""; |
| 10 | 1993 | public String returns = ""; |
| 11 | 1993 | public Set modifiers = new HashSet(); |
| 12 | 1993 | public List params = new ArrayList(); |
| 13 | 1993 | public Set exceptions = new HashSet(); |
| 14 | 1993 | public boolean constructor = false; |
| 15 | |
public int dimensions; |
| 16 | |
public String body; |
| 17 | |
|
| 18 | |
public boolean equals(Object obj) { |
| 19 | 56 | MethodDef methodDef = (MethodDef) obj; |
| 20 | 56 | return methodDef.name.equals(name) |
| 21 | |
&& methodDef.returns.equals(returns) |
| 22 | |
&& methodDef.modifiers.equals(modifiers) |
| 23 | |
&& methodDef.params.equals(params) |
| 24 | |
&& methodDef.exceptions.equals(exceptions) |
| 25 | |
&& methodDef.constructor == constructor |
| 26 | |
&& methodDef.dimensions == dimensions; |
| 27 | |
} |
| 28 | |
|
| 29 | |
public int hashCode() { |
| 30 | 1 | return name.hashCode() + returns.hashCode() + |
| 31 | |
modifiers.hashCode() + params.hashCode() + |
| 32 | |
params.hashCode() + exceptions.hashCode() + |
| 33 | |
dimensions + (constructor ? 0 : 1); |
| 34 | |
} |
| 35 | |
|
| 36 | |
public String toString() { |
| 37 | 28 | StringBuffer result = new StringBuffer(); |
| 38 | 28 | result.append(modifiers); |
| 39 | 28 | result.append(' '); |
| 40 | 28 | result.append(returns); |
| 41 | 28 | for (int i = 0; i < dimensions; i++) result.append("[]"); |
| 42 | 28 | result.append(' '); |
| 43 | 28 | result.append(name); |
| 44 | 28 | result.append('('); |
| 45 | 28 | result.append(params); |
| 46 | 28 | result.append(')'); |
| 47 | 28 | result.append(" throws "); |
| 48 | 28 | result.append(exceptions); |
| 49 | 28 | result.append(body); |
| 50 | 28 | return result.toString(); |
| 51 | |
} |
| 52 | |
} |