1 15 package org.apache.hivemind.annotations.internal; 16 17 import java.lang.reflect.Method ; 18 19 import org.apache.hivemind.Location; 20 import org.apache.hivemind.Resource; 21 22 28 public final class AnnotatedModuleLocation implements Location 29 { 30 private Resource _resource; 31 private Class _moduleClass; 32 private Method _method; 33 34 public AnnotatedModuleLocation(Resource resource, Class moduleClass, Method method) 35 { 36 _resource = resource; 37 _moduleClass = moduleClass; 38 _method = method; 39 } 40 41 public AnnotatedModuleLocation(Resource resource, Class moduleClass) 42 { 43 this(resource, moduleClass, null); 44 } 45 46 public Resource getResource() 47 { 48 return _resource; 49 } 50 51 public Method getMethod() 52 { 53 return _method; 54 } 55 56 public Class getModuleClass() 57 { 58 return _moduleClass; 59 } 60 61 public int hashCode() 62 { 63 return ((237 + _resource.hashCode()) + 13 * _moduleClass.hashCode()) 64 + (_method != null ? _method.hashCode() : 0); 65 } 66 67 public boolean equals(Object other) 68 { 69 if (!(other instanceof AnnotatedModuleLocation)) 70 return false; 71 72 AnnotatedModuleLocation l = (AnnotatedModuleLocation) other; 73 74 if (_moduleClass.equals(l.getModuleClass())) 75 return false; 76 77 if (_method.equals(l.getMethod())) 78 return false; 79 80 return _resource.equals(l.getResource()); 81 } 82 83 88 public String getPosition() 89 { 90 String result = "Class " + _moduleClass.getName(); 91 if (_method != null) { 92 result += ", method " + _method.getName(); 93 } 94 return result; 95 } 96 97 public String toString() 98 { 99 return getPosition(); 100 } 101 102 } 103 | Popular Tags |