Class ModuleSorter


  • public final class ModuleSorter
    extends Object
    A dependency sorter for jigsaw modules.
    Author:
    harald
    • Field Detail

      • INSTANCE

        public static final ModuleSorter INSTANCE
        The singleton.
    • Constructor Detail

      • ModuleSorter

        public ModuleSorter()
        Creates a module sorter and loads the module hierarchy.

        Finds all named modules providing a ModuleHook via module-info and sorts them according to their dependencies.

    • Method Detail

      • getModuleInfos

        public List<ModuleInfo> getModuleInfos()
        Gets the modules infos ordered by dependency.
        Modules at the top of the dependency hierarchy come last, modules without further dependencies come first.
        Returns:
        the module infos
      • getModuleInfo

        public ModuleInfo getModuleInfo​(String name)
        Gets the module info for a module name.
        Parameters:
        name - the module name
        Returns:
        the module info, null if no such (application) module or module has no ModuleHook.
      • getModuleInfo

        public ModuleInfo getModuleInfo​(URL url)
        Gets the module info for a given URL.
        Parameters:
        url - the resource url
        Returns:
        the module info, null if application not modularized, not from a module or module does not provide a ModuleHook.
      • sort

        public Collection<URL> sort​(Enumeration<URL> urls,
                                    String serviceName)
        Sorts an enumeration of urls according to the module hierarchy.
        The highest module ordinal comes first.
        Parameters:
        urls - the urls, usually from ClassLoader.getResources
        serviceName - the service name
        Returns:
        the sorted urls