Changed Context#getAnnotationMirror to use the annotation class argument

This commit is contained in:
collinsmith
2020-12-15 13:31:48 -08:00
parent 06461b76c7
commit 9656bcc382
2 changed files with 10 additions and 2 deletions

View File

@ -27,9 +27,17 @@ class Context {
elementUtils = processingEnvironment.getElementUtils();
}
/**
* @deprecated use {@link #getAnnotationMirror(Element, ClassName)} with cached value
*/
@Deprecated
AnnotationMirror getAnnotationMirror(Element element, Class<? extends Annotation> annotationClass) {
return getAnnotationMirror(element, ClassName.get(annotationClass));
}
AnnotationMirror getAnnotationMirror(Element element, ClassName annotationClass) {
for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
if (Constants.PRIMARY_KEY.equals(ClassName.get(annotationMirror.getAnnotationType()))) {
if (annotationClass.equals(ClassName.get(annotationMirror.getAnnotationType()))) {
return annotationMirror;
}
}

View File

@ -44,7 +44,7 @@ class PrimaryKeyElement {
primaryKeyElement = firstAcceptableElement;
}
AnnotationMirror primaryKeyMirror = context.getAnnotationMirror(primaryKeyElement, PrimaryKey.class);
AnnotationMirror primaryKeyMirror = context.getAnnotationMirror(primaryKeyElement, Constants.PRIMARY_KEY);
return new PrimaryKeyElement(primaryKeyElement, primaryKeyMirror);
}