use of org.qi4j.api.mixin.Mixins in project qi4j-sdk by Qi4j.
the class AnnotationsTest method getAnnotationOrNull.
@Test
public void getAnnotationOrNull() throws NoSuchMethodException {
assertNotNull("Mixins annotation found", Annotations.annotationOn(AnnotatedClass.class, Mixins.class));
assertNull("No SideEffects annotation found", Annotations.annotationOn(AnnotatedClass.class, SideEffects.class));
final Type returnType = AnnotatedClass.class.getDeclaredMethod("list").getGenericReturnType();
assertNull("Null on no class type", Annotations.annotationOn(returnType, Mixins.class));
}
use of org.qi4j.api.mixin.Mixins in project qi4j-sdk by Qi4j.
the class CompositeAssemblyImpl method mixinDeclarations.
protected Iterable<Class<?>> mixinDeclarations(Iterable<? extends Class<?>> typess) {
// Find mixin declarations
ArrayList<Type> allTypes = new ArrayList<Type>();
for (Class<?> type : typess) {
Iterable<Type> types = typesOf(type);
Iterables.addAll(allTypes, types);
}
// Find all mixins and flattern them into an iterable
Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>() {
@Override
public Iterable<Class<?>> map(Type type) {
Mixins mixins = Annotations.annotationOn(type, Mixins.class);
if (mixins == null) {
return Iterables.empty();
} else {
return iterable(mixins.value());
}
}
};
Iterable<Class<?>> flatten = Iterables.flattenIterables(Iterables.map(function, allTypes));
return Iterables.toList(flatten);
}