if (method == null) {
return false;
}
AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
Declarations decls = env.getDeclarationUtils();
Declaration unwrappedMethod = method.getDelegate();
while (unwrappedMethod instanceof DecoratedDeclaration) {
unwrappedMethod = ((DecoratedDeclaration) unwrappedMethod).getDelegate();
}
TypeDeclaration declaringType = method.getDeclaringType();
if (declaringType instanceof ClassDeclaration) {
declaringType = ((ClassDeclaration) declaringType).getSuperclass().getDeclaration();
while (declaringType instanceof ClassDeclaration && !Object.class.getName().equals(declaringType.getQualifiedName())) {
Collection<? extends MethodDeclaration> methods = declaringType.getMethods();
for (Declaration candidate : methods) {
while (candidate instanceof DecoratedDeclaration) {
//unwrap the candidate.
candidate = ((DecoratedDeclaration) candidate).getDelegate();
}
if (decls.overrides((MethodDeclaration) candidate, (MethodDeclaration) unwrappedMethod)) {
return true;
}
}
declaringType = ((ClassDeclaration) declaringType).getSuperclass().getDeclaration();