Search in sources :

Example 1 with MetaInfoHolder

use of org.qi4j.api.structure.MetaInfoHolder in project qi4j-sdk by Qi4j.

the class InstanceImporter method importService.

@Override
public T importService(final ImportedServiceDescriptor serviceDescriptor) throws ServiceImporterException {
    T instance = null;
    Iterable<MetaInfoHolder> holders = Iterables.iterable(serviceDescriptor, module, layer, application);
    for (final MetaInfoHolder metaInfoHolder : holders) {
        Function<Class<?>, T> metaFinder = new Function<Class<?>, T>() {

            @Override
            @SuppressWarnings("unchecked")
            public T map(Class<?> type) {
                return (T) metaInfoHolder.metaInfo(type);
            }
        };
        instance = first(filter(notNull(), map(metaFinder, serviceDescriptor.types())));
        if (instance != null) {
            break;
        }
    }
    return instance;
}
Also used : MetaInfoHolder(org.qi4j.api.structure.MetaInfoHolder) Function(org.qi4j.functional.Function)

Aggregations

MetaInfoHolder (org.qi4j.api.structure.MetaInfoHolder)1 Function (org.qi4j.functional.Function)1