Assuming you are using annotation
@Author("fred")
public class MyClass {...
Then here is the method that will do this
public List<Class> getClassesWrittenBy(String name, List<Class> classList) {
List<Class> list = new LinkedList<Class>();
for (Class clazz: classList)
if (clazz.isAnnotationPresent(Author.class)) {
Author author = clazz.getAnnotation(Author.class);
if (author.value().equals(name))
list.add(clazz);
}
return (list);
}
source
share