OrderedSPIRegistry { public static <T extends OrderedSPI<?>> Map<Class<?>, T> getRegisteredServicesByClass(final Collection<Class<?>> types, final Class<T> orderedSPIClass) { Collection<T> registeredServices = getRegisteredServices(orderedSPIClass); Map<Class<?>, T> result = new LinkedHashMap<>(registeredServices.size(), 1); for (T each : registeredServices) { types.stream().filter(type -> ((OrderedSPI<?>) each).getTypeClass() == type).forEach(type -> result.put(type, each)); } return result; }  static Map<Class<?>, T> getRegisteredServicesByClass(final Collection<Class<?>> types, final Class<T> orderedSPIClass); static Map<K, V> getRegisteredServices(final Collection<K> types, final Class<V> orderedSPIClass);  }
@Test public void assertGetRegisteredServicesByClass() { Collection<FixtureCustomInterface> customInterfaceCollection = new LinkedList<>(); customInterfaceCollection.add(new FixtureCustomInterfaceImpl()); Collection<Class<?>> collection = customInterfaceCollection.stream().map(Object::getClass).collect(Collectors.toList()); Map<Class<?>, OrderedSPIFixture> actual = OrderedSPIRegistry.getRegisteredServicesByClass(collection, OrderedSPIFixture.class); assertThat(actual.size(), is(1)); }