1 54 package org.logicalcobwebs.cglib.core; 55 56 import org.logicalcobwebs.asm.Type; 57 58 62 public class Signature { 63 private String name; 64 private String desc; 65 66 public Signature(String name, String desc) { 67 if (name.indexOf('(') >= 0) { 69 throw new IllegalArgumentException ("Name '" + name + "' is invalid"); 70 } 71 this.name = name; 72 this.desc = desc; 73 } 74 75 public Signature(String name, Type returnType, Type[] argumentTypes) { 76 this(name, Type.getMethodDescriptor(returnType, argumentTypes)); 77 } 78 79 public String getName() { 80 return name; 81 } 82 83 public String getDescriptor() { 84 return desc; 85 } 86 87 public Type getReturnType() { 88 return Type.getReturnType(desc); 89 } 90 91 public Type[] getArgumentTypes() { 92 return Type.getArgumentTypes(desc); 93 } 94 95 public String toString() { 96 return name + desc; 97 } 98 99 public boolean equals(Object o) { 100 if (o == null) 101 return false; 102 if (!(o instanceof Signature)) 103 return false; 104 Signature other = (Signature)o; 105 return name.equals(other.name) && desc.equals(other.desc); 106 } 107 108 public int hashCode() { 109 return name.hashCode() ^ desc.hashCode(); 110 } 111 } 112 | Popular Tags |