All Downloads are FREE. Search and download functionalities are using the official Maven repository.

japicmp.filter.AnnotationClassFilter Maven / Gradle / Ivy

Go to download

japicmp is a library that computes the differences between two versions of a jar file/artifact in order to ease the API documentation for clients/customers.

There is a newer version: 0.23.0
Show newest version
package japicmp.filter;

import javassist.CtClass;
import javassist.NotFoundException;

import java.util.logging.Level;
import java.util.logging.Logger;

public class AnnotationClassFilter extends AnnotationFilterBase implements ClassFilter {
	private static final Logger LOGGER = Logger.getLogger(AnnotationBehaviorFilter.class.getName());

	public AnnotationClassFilter(String filterString) {
		super(filterString.substring(1));
	}

	@Override
	public boolean matches(CtClass ctClass) {
		boolean matches = ctClass.hasAnnotation(annotationClassName);
		if (!matches) {
            try {
				CtClass declaringClass = ctClass.getDeclaringClass();
				if (declaringClass != null) {
					matches = declaringClass.hasAnnotation(annotationClassName);
				}
            } catch (NotFoundException e) {
				LOGGER.log(Level.FINE, "Failed to load class '" + ctClass.getName() + "': " + e.getLocalizedMessage(), e);
            }
        }
		return matches;
	}

	@Override
	public String toString() {
		return "@" + annotationClassName;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy