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();
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() {
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)