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

com.github.slavaz.maven.plugin.postgresql.embedded.classloader.ClassLoaderHolder Maven / Gradle / Ivy

package com.github.slavaz.maven.plugin.postgresql.embedded.classloader;

import org.apache.commons.lang3.Validate;

import java.util.Optional;

public class ClassLoaderHolder {

    @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
    private static Optional instance = Optional.empty();

    private ClassLoaderHolder() {
    }

    public static void setClassLoader(final ClassLoader classLoader) {
        Validate.notNull(classLoader);
        if (instance.isPresent()) {
            throw new IllegalStateException("ClassLoader instance already set");
        }
        instance = Optional.of(classLoader);
    }

    public static Optional getClassLoader() {
        return instance;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy