OrderedSPIRegistry { public static <K, V extends OrderedSPI<?>> Map<K, V> getRegisteredServices(final Collection<K> types, final Class<V> orderedSPIClass) { Collection<V> registeredServices = getRegisteredServices(orderedSPIClass); Map<K, V> result = new LinkedHashMap<>(registeredServices.size(), 1); for (V each : registeredServices) { types.stream().filter(type -> each.getTypeClass() == type.getClass()).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 assertGetRegisteredServices() { Collection<FixtureCustomInterface> collection = new LinkedList<>(); collection.add(new FixtureCustomInterfaceImpl()); Map<FixtureCustomInterface, OrderedSPIFixture> actual = OrderedSPIRegistry.getRegisteredServices(collection, OrderedSPIFixture.class); assertThat(actual.size(), is(1)); }