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

io.legaldocml.module.Modules Maven / Gradle / Ivy

The newest version!
package io.legaldocml.module;

import com.google.common.collect.ImmutableMap;
import io.legaldocml.util.CharArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ServiceLoader;

/**
 * @author Jacques Militello
 */
public final class Modules {

    /**
     * SLF4J Logger.
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(Modules.class);

    private static final ImmutableMap ALL_MODULES;

    static {
        ImmutableMap.Builder builder = ImmutableMap.builder();

        ServiceLoader.load(Module.class).forEach(c -> {
            LOGGER.info("load Module [{}]", c);
            builder.put(c.namespace(), c);
        });
        ALL_MODULES = builder.build();
    }

    private Modules(){
    }

    public static Module get(CharArray key) {
        return ALL_MODULES.get(key);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy