@Test public void shouldReturnOneWithPredicate() { final Predicate<Object> computer = o -> o.getClass().getSimpleName().equals("Computer"); Machine machine = ServiceLoaderProvider.getUnique(Machine.class, computer); Assertions.assertNotNull(machine); Assertions.assertTrue(machine instanceof Computer); }
public static <T> T getUnique(Class<T> supplier) { return getUniqueSupplier(supplier, null); }
ServiceLoaderProvider { public static <T> T getUnique(Class<T> supplier) { return getUniqueSupplier(supplier, null); } }
ServiceLoaderProvider { public static <T> T getUnique(Class<T> supplier) { return getUniqueSupplier(supplier, null); } private  ServiceLoaderProvider(); }
ServiceLoaderProvider { public static <T> T getUnique(Class<T> supplier) { return getUniqueSupplier(supplier, null); } private  ServiceLoaderProvider(); static T get(Class<T> supplier); static T getUnique(Class<T> supplier); static T getUnique(Class<T> supplier, Predicate<Object> predicate); static I getUnique(Class<T> supplier, Class<I> supplierImplementation); static Stream<Object> getSupplierStream(Class<T> supplier); }
ServiceLoaderProvider { public static <T> T getUnique(Class<T> supplier) { return getUniqueSupplier(supplier, null); } private  ServiceLoaderProvider(); static T get(Class<T> supplier); static T getUnique(Class<T> supplier); static T getUnique(Class<T> supplier, Predicate<Object> predicate); static I getUnique(Class<T> supplier, Class<I> supplierImplementation); static Stream<Object> getSupplierStream(Class<T> supplier);  }