@Test public void testLookupServiceNegative() throws Exception { assertThat(CdiUtil.lookupService(CdiUtil.class), nullValue()); }
static <T> T lookupService(final Class<T> clazz) { final List<RankedProvider<T>> providers = new LinkedList<>(); for (final T provider : ServiceFinder.find(clazz)) { providers.add(new RankedProvider<>(provider)); } Collections.sort(providers, new RankedComparator<T>(RankedComparator.Order.ASCENDING)); return providers.isEmpty() ? null : providers.get(0).getProvider(); }
CdiUtil { static <T> T lookupService(final Class<T> clazz) { final List<RankedProvider<T>> providers = new LinkedList<>(); for (final T provider : ServiceFinder.find(clazz)) { providers.add(new RankedProvider<>(provider)); } Collections.sort(providers, new RankedComparator<T>(RankedComparator.Order.ASCENDING)); return providers.isEmpty() ? null : providers.get(0).getProvider(); } }
CdiUtil { static <T> T lookupService(final Class<T> clazz) { final List<RankedProvider<T>> providers = new LinkedList<>(); for (final T provider : ServiceFinder.find(clazz)) { providers.add(new RankedProvider<>(provider)); } Collections.sort(providers, new RankedComparator<T>(RankedComparator.Order.ASCENDING)); return providers.isEmpty() ? null : providers.get(0).getProvider(); } private  CdiUtil(); }
CdiUtil { static <T> T lookupService(final Class<T> clazz) { final List<RankedProvider<T>> providers = new LinkedList<>(); for (final T provider : ServiceFinder.find(clazz)) { providers.add(new RankedProvider<>(provider)); } Collections.sort(providers, new RankedComparator<T>(RankedComparator.Order.ASCENDING)); return providers.isEmpty() ? null : providers.get(0).getProvider(); } private  CdiUtil(); static Annotation[] getQualifiers(final Annotation[] annotations); static BeanManager getBeanManager(); static Class<? extends Annotation> getBeanScope(final Class<?> beanClass, final BeanManager beanManager); }
CdiUtil { static <T> T lookupService(final Class<T> clazz) { final List<RankedProvider<T>> providers = new LinkedList<>(); for (final T provider : ServiceFinder.find(clazz)) { providers.add(new RankedProvider<>(provider)); } Collections.sort(providers, new RankedComparator<T>(RankedComparator.Order.ASCENDING)); return providers.isEmpty() ? null : providers.get(0).getProvider(); } private  CdiUtil(); static Annotation[] getQualifiers(final Annotation[] annotations); static BeanManager getBeanManager(); static Class<? extends Annotation> getBeanScope(final Class<?> beanClass, final BeanManager beanManager);  }