use of org.qi4j.api.activation.Activators in project qi4j-sdk by Qi4j.
the class ServiceAssemblyImpl method activatorsDeclarations.
protected Iterable<Class<? extends Activator<?>>> activatorsDeclarations(Iterable<? extends Class<?>> typess) {
// Find activator declarations
ArrayList<Type> allTypes = new ArrayList<Type>();
for (Class<?> type : typess) {
Iterable<Type> types = Classes.typesOf(type);
Iterables.addAll(allTypes, types);
}
// Find all activators and flattern them into an iterable
Function<Type, Iterable<Class<? extends Activator<?>>>> function = new Function<Type, Iterable<Class<? extends Activator<?>>>>() {
@Override
public Iterable<Class<? extends Activator<?>>> map(Type type) {
Activators activators = Annotations.annotationOn(type, Activators.class);
if (activators == null) {
return Iterables.empty();
} else {
return Iterables.iterable(activators.value());
}
}
};
Iterable<Class<? extends Activator<?>>> flatten = Iterables.flattenIterables(Iterables.map(function, allTypes));
return Iterables.toList(flatten);
}
Aggregations