- java.lang.Object
-
- org.tentackle.common.ModuleSorter
-
public final class ModuleSorter extends java.lang.ObjectA dependency sorter for jigsaw modules.- Author:
- harald
-
-
Field Summary
Fields Modifier and Type Field Description static ModuleSorterINSTANCEThe singleton.
-
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 ModuleInfogetModuleInfo(java.lang.String name)Gets the module info for a module name.ModuleInfogetModuleInfo(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.StringtoString()
-
-
-
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
ModuleHookvia module-info and sorts them according to their dependencies.
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.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.getResourcesserviceName- the service name- Returns:
- the sorted urls
-
-