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

com.teamscale.commons.annotation.ClassIndexUtils Maven / Gradle / Ivy

package com.teamscale.commons.annotation;

import java.lang.annotation.Annotation;
import java.util.stream.Collectors;

import org.atteo.classindex.ClassIndex;

import com.google.common.collect.Streams;

/** Wrapper to retrieve annotated classes. */
public class ClassIndexUtils {

	/**
	 * Returns all classes annotated with the given annotation. This is workaround
	 * for https://github.com/atteo/classindex/issues/54.
	 */
	public static Iterable> getAnnotated(Class annotation) {
		Iterable> annotated = ClassIndex.getAnnotated(annotation);
		return Streams.stream(annotated).filter(clazz -> clazz.getAnnotation(annotation) != null)
				.collect(Collectors.toList());
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy