]> source.dussan.org Git - aspectj.git/commitdiff
227993: annotation value matching support for field annotations. plus hashcode/equals...
authoraclement <aclement>
Sat, 10 May 2008 04:25:31 +0000 (04:25 +0000)
committeraclement <aclement>
Sat, 10 May 2008 04:25:31 +0000 (04:25 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelField.java
weaver/src/org/aspectj/weaver/patterns/ExactAnnotationTypePattern.java
weaver/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java

index b2a7e6b0d5369ce6f296bbae067e26ca492d2c66..c54b92869120a6ad6880dc61557b8cbf299c635e 100644 (file)
@@ -119,7 +119,15 @@ final class BcelField extends ResolvedMemberImpl {
                ensureAnnotationTypesRetrieved();
                return annotations;
        }
-    
+       
+       public AnnotationX getAnnotationOfType(UnresolvedType ofType) {
+        ensureAnnotationTypesRetrieved();
+        for (int i=0; i<annotations.length; i++) {
+            if (annotations[i].getTypeName().equals(ofType.getName())) return annotations[i];
+        }
+        return null;
+    }    
+       
        private void ensureAnnotationTypesRetrieved() {
                if (annotationTypes == null) {
                Annotation annos[] = field.getAnnotations();
index 0dafaedd7e2cc4d6d4f3098c66643e700bd8aef2..3935328727c72e6daa627a4b8a298627eb6ede3e 100644 (file)
@@ -379,14 +379,15 @@ public class ExactAnnotationTypePattern extends AnnotationTypePattern {
        public boolean equals(Object obj) {
                if (!(obj instanceof ExactAnnotationTypePattern)) return false;
                ExactAnnotationTypePattern other = (ExactAnnotationTypePattern) obj;
-               return (other.annotationType.equals(annotationType)) && isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch();
+               return (other.annotationType.equals(annotationType)) && isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch() &&
+        (annotationValues==null?other.annotationValues==null:annotationValues.equals(other.annotationValues));
        }
        
        /* (non-Javadoc)
         * @see java.lang.Object#hashCode()
         */
        public int hashCode() {
-               return annotationType.hashCode()*37+(isForParameterAnnotationMatch()?0:1);
+        return (((annotationType.hashCode())*37+(isForParameterAnnotationMatch()?0:1))*37)+(annotationValues==null?0:annotationValues.hashCode());
        }
        
        public String toString() {
index 0bbfa1e079f10cddfb9dbc1785d33ce7b67e0089..362c1b045c30a26c74eb494c989ce21a3357a938 100644 (file)
@@ -344,14 +344,16 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
        public boolean equals(Object obj) {
                if (!(obj instanceof WildAnnotationTypePattern)) return false;
                WildAnnotationTypePattern other = (WildAnnotationTypePattern) obj;
-               return other.typePattern.equals(typePattern) && this.isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch();
+               return other.typePattern.equals(typePattern) && 
+                   this.isForParameterAnnotationMatch()==other.isForParameterAnnotationMatch() &&
+                   (annotationValues==null?other.annotationValues==null:annotationValues.equals(other.annotationValues));
        }
        
        /* (non-Javadoc)
         * @see java.lang.Object#hashCode()
         */
        public int hashCode() {
-               return (17 + 37*typePattern.hashCode())*37+(isForParameterAnnotationMatch()?0:1);
+               return (((17 + 37*typePattern.hashCode())*37+(isForParameterAnnotationMatch()?0:1))*37)+(annotationValues==null?0:annotationValues.hashCode());
        }
        
        /* (non-Javadoc)