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

io.swagger.servlet.extensions.ReaderExtensions Maven / Gradle / Ivy

There is a newer version: 1.6.14
Show newest version
package io.swagger.servlet.extensions;

import com.google.common.collect.Ordering;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

public class ReaderExtensions {

    private static final Logger LOGGER = LoggerFactory.getLogger(ReaderExtensions.class);
    private static final List extensions;

    public static List getExtensions() {
        return extensions;
    }

    static {
        final Ordering ordering = new Ordering() {
            @Override
            public int compare(ReaderExtension left, ReaderExtension right) {
                return Integer.compare(left.getPriority(), right.getPriority());
            }
        };
        final List loadedExtensions = new ArrayList<>();
        for (ReaderExtension readerExtension : ordering.sortedCopy(ServiceLoader.load(ReaderExtension.class))) {
            LOGGER.debug("adding extension " + readerExtension);
            loadedExtensions.add(readerExtension);
        }
        extensions = Collections.unmodifiableList(loadedExtensions);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy