1 25 26 package org.objectweb.easybeans.deployment.annotations; 27 28 import java.lang.reflect.Method ; 29 import java.util.Arrays ; 30 31 import org.objectweb.asm.Type; 32 33 38 public class JMethod { 39 40 43 private String name = null; 44 45 48 private int access; 49 50 53 private String descriptor = null; 54 55 58 private String signature; 59 60 63 private String [] exceptions; 64 65 79 public JMethod(final int access, final String name, final String descriptor, final String signature, 80 final String [] exceptions) { 81 this.access = access; 82 this.name = name; 83 this.descriptor = descriptor; 84 this.signature = signature; 85 this.exceptions = exceptions; 86 } 87 88 91 public int getAccess() { 92 return access; 93 } 94 95 99 public JMethod(final Method m) { 100 this.name = m.getName(); 101 this.descriptor = Type.getMethodDescriptor(m); 102 } 106 107 112 @Override 113 public boolean equals(final Object obj) { 114 if (obj != null && obj instanceof JMethod) { 115 JMethod other = (JMethod) obj; 116 117 if (!this.name.equals(other.name)) { 119 return false; 120 } 121 122 if ((this.descriptor != null) && (!this.descriptor.equals(other.descriptor))) { 124 return false; 125 } 126 127 133 134 return true; 136 } 137 return false; 138 } 139 140 143 @Override 144 public int hashCode() { 145 return name.hashCode(); 146 } 147 148 151 public String getDescriptor() { 152 return descriptor; 153 } 154 155 158 public String [] getExceptions() { 159 return exceptions; 160 } 161 162 165 public String getName() { 166 return name; 167 } 168 169 172 public String getSignature() { 173 return signature; 174 } 175 176 179 @Override 180 public String toString() { 181 StringBuilder sb = new StringBuilder (); 182 sb.append(this.getClass().getName().substring(this.getClass().getPackage().getName().length() + 1)); 184 185 sb.append("[name="); 187 sb.append(name); 188 189 sb.append(", access="); 191 sb.append(access); 192 193 if (descriptor != null) { 195 sb.append(", descriptor="); 196 sb.append(descriptor); 197 } 198 199 if (signature != null) { 201 sb.append(", signature="); 202 sb.append(signature); 203 } 204 205 if (exceptions != null) { 207 sb.append(", exceptions="); 208 sb.append(Arrays.asList(exceptions)); 209 } 210 sb.append("]"); 211 return sb.toString(); 212 } 213 } 214 | Popular Tags |