Class ModuleSorter


  • public final class ModuleSorter
    extends java.lang.Object
    A dependency sorter for jigsaw modules.
    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      ModuleSorter()
      Creates a module sorter and loads the module hierarchy.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ModuleInfo getModuleInfo​(java.lang.String name)
      Gets the module info for a module name.
      ModuleInfo getModuleInfo​(java.net.URL url)
      Gets the module info for a given URL.
      java.util.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.
      java.util.Collection<java.net.URL> sort​(java.util.Enumeration<java.net.URL> urls, java.lang.String serviceName)
      Sorts an enumeration of urls according to the module hierarchy.
      The top of the hierarchy comes first.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getModuleInfos

        public java.util.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​(java.lang.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​(java.net.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 java.util.Collection<java.net.URL> sort​(java.util.Enumeration<java.net.URL> urls,
                                                       java.lang.String serviceName)
        Sorts an enumeration of urls according to the module hierarchy.
        The top of the hierarchy comes first.
        Parameters:
        urls - the urls, usually from ClassLoader.getResources
        serviceName - the service name
        Returns:
        the sorted urls