All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.sskorol.utils.ServiceLoaderUtils Maven / Gradle / Ivy

Go to download

WebDriver Supplier library, which helps to effectively manage web browser sessions.

There is a newer version: 1.1.3
Show newest version
package io.github.sskorol.utils;

import io.vavr.control.Try;
import lombok.extern.slf4j.Slf4j;
import one.util.streamex.StreamEx;

import java.util.Collections;
import java.util.List;
import java.util.ServiceLoader;

@Slf4j
@SuppressWarnings("JavadocType")
public final class ServiceLoaderUtils {

    private ServiceLoaderUtils() {
        throw new UnsupportedOperationException("Illegal access to private constructor");
    }

    public static  List load(final Class type, final ClassLoader classLoader) {
        return Try.of(() -> StreamEx.of(ServiceLoader.load(type, classLoader).iterator()).toList())
                  .getOrElseGet(ex -> Collections.emptyList());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy