1 package org.apache.ws.jaxme.js.pattern; 2 3 import org.apache.ws.jaxme.js.JavaMethod; 4 import org.apache.ws.jaxme.js.Parameter; 5 6 7 12 public class MethodKey implements Comparable { 13 private JavaMethod method; 14 15 17 public MethodKey(JavaMethod pMethod) { 18 method = pMethod; 19 } 20 21 26 public boolean equals(Object o) { 27 if (o == null || !(o instanceof MethodKey)) { return false; } 28 return compareTo(o) == 0; 29 } 30 31 36 public int compareTo(Object o) { 37 MethodKey other = (MethodKey) o; 38 int result = method.getName().compareTo(other.method.getName()); 39 if (result != 0) { 40 return result; 41 } 42 Parameter[] params = method.getParams(); 43 Parameter[] oparams = other.method.getParams(); 44 result = params.length - oparams.length; 45 if (result != 0) { 46 return result; 47 } 48 for (int i = 0; i < params.length; i++) { 49 result = params[i].getType().toString().compareTo(oparams[i].getType().toString()); 50 if (result != 0) { 51 return result; 52 } 53 } 54 return 0; 55 } 56 public int hashCode() { 57 int result = method.getName().hashCode(); 58 Parameter[] params = method.getParams(); 59 result += params.length; 60 for (int i = 0; i < params.length; i++) { 61 result += params[i].getType().toString().hashCode(); 62 } 63 return result; 64 } 65 } | Popular Tags |