1 16 package net.sf.cglib.core; 17 18 import org.objectweb.asm.Type; 19 20 24 public class Signature { 25 private String name; 26 private String desc; 27 28 public Signature(String name, String desc) { 29 if (name.indexOf('(') >= 0) { 31 throw new IllegalArgumentException ("Name '" + name + "' is invalid"); 32 } 33 this.name = name; 34 this.desc = desc; 35 } 36 37 public Signature(String name, Type returnType, Type[] argumentTypes) { 38 this(name, Type.getMethodDescriptor(returnType, argumentTypes)); 39 } 40 41 public String getName() { 42 return name; 43 } 44 45 public String getDescriptor() { 46 return desc; 47 } 48 49 public Type getReturnType() { 50 return Type.getReturnType(desc); 51 } 52 53 public Type[] getArgumentTypes() { 54 return Type.getArgumentTypes(desc); 55 } 56 57 public String toString() { 58 return name + desc; 59 } 60 61 public boolean equals(Object o) { 62 if (o == null) 63 return false; 64 if (!(o instanceof Signature)) 65 return false; 66 Signature other = (Signature)o; 67 return name.equals(other.name) && desc.equals(other.desc); 68 } 69 70 public int hashCode() { 71 return name.hashCode() ^ desc.hashCode(); 72 } 73 } 74 | Popular Tags |