class OrmFactoryRegistryImpl implements OrmFactoryRegistry {

    @Override
    @SuppressWarnings("unchecked")
    public <T extends Thing> Optional<OrmFactory<T>> getFactoryOfType(Class<T> type) {
        return factories.stream()
                .filter(factory -> type.equals(factory.getType()))
                .map(factory -> (OrmFactory<T>) factory)
                .findFirst();
    }

}