com.github.yoojia.events.AnnotatedFinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of halo-events Show documentation
Show all versions of halo-events Show documentation
Tiny event bus like Guava.EventBus
package com.github.yoojia.events;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
* @author YOOJIA.CHEN ([email protected])
* @version 2015-09-09
*/
class AnnotatedFinder {
private final Object object;
public AnnotatedFinder(Object object) {
this.object = object;
}
public List find() {
final List array = new ArrayList<>();
final Class> type = object.getClass();
final Method[] methods = type.getDeclaredMethods();
for (Method method : methods) {
final Subscribe subscribe = method.getAnnotation(Subscribe.class);
if (subscribe == null) {
continue;
}
array.add(new SubscribeMeta(object, method));
}
return array;
}
}