Search in sources :

Example 1 with Concerns

use of org.qi4j.api.concern.Concerns in project qi4j-sdk by Qi4j.

the class CompositeAssemblyImpl method concernDeclarations.

private Iterable<Class<?>> concernDeclarations(ArrayList<Type> allTypes) {
    // Find all concerns and flattern them into an iterable
    Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>() {

        @Override
        public Iterable<Class<?>> map(Type type) {
            Concerns concerns = Annotations.annotationOn(type, Concerns.class);
            if (concerns == null) {
                return empty();
            } else {
                return iterable(concerns.value());
            }
        }
    };
    Iterable<Class<?>> flatten = flattenIterables(map(function, allTypes));
    return toList(flatten);
}
Also used : Function(org.qi4j.functional.Function) Annotations.isType(org.qi4j.api.util.Annotations.isType) Type(java.lang.reflect.Type) Concerns(org.qi4j.api.concern.Concerns) Classes.wrapperClass(org.qi4j.api.util.Classes.wrapperClass)

Example 2 with Concerns

use of org.qi4j.api.concern.Concerns in project qi4j-sdk by Qi4j.

the class CompositeAssemblyImpl method concernDeclarations.

private Iterable<Class<?>> concernDeclarations(Iterable<? extends Class<?>> typess) {
    // Find concern declarations
    ArrayList<Type> allTypes = new ArrayList<Type>();
    for (Class<?> type : typess) {
        Iterable<Type> types;
        if (type.isInterface()) {
            types = typesOf(type);
        } else {
            types = Iterables.<Type>cast(classHierarchy(type));
        }
        Iterables.addAll(allTypes, types);
    }
    // Find all concerns and flattern them into an iterable
    Function<Type, Iterable<Class<?>>> function = new Function<Type, Iterable<Class<?>>>() {

        @Override
        public Iterable<Class<?>> map(Type type) {
            Concerns concerns = Annotations.annotationOn(type, Concerns.class);
            if (concerns == null) {
                return Iterables.empty();
            } else {
                return iterable(concerns.value());
            }
        }
    };
    Iterable<Class<?>> flatten = Iterables.flattenIterables(Iterables.map(function, allTypes));
    return Iterables.toList(flatten);
}
Also used : Function(org.qi4j.functional.Function) Type(java.lang.reflect.Type) ArrayList(java.util.ArrayList) Concerns(org.qi4j.api.concern.Concerns)

Aggregations

Type (java.lang.reflect.Type)2 Concerns (org.qi4j.api.concern.Concerns)2 Function (org.qi4j.functional.Function)2 ArrayList (java.util.ArrayList)1 Annotations.isType (org.qi4j.api.util.Annotations.isType)1 Classes.wrapperClass (org.qi4j.api.util.Classes.wrapperClass)1