Package org.jfree.base.modules
Class PackageSorter
- java.lang.Object
-
- org.jfree.base.modules.PackageSorter
-
public final class PackageSorter extends java.lang.Object
Compares two modules for order. A module is considered less than an other module if the module is a required module of the compared module. Modules are considered equal if they have no relation.When sorting, we match this modules position against all dependent modules until all positions are stable. Circular references are evil and are filtered during the module loading process in the package manager.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PackageSorter.SortModule
An Internal wrapper class which collects additional information on the given module.
-
Constructor Summary
Constructors Modifier Constructor Description private
PackageSorter()
DefaultConstructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.util.ArrayList
collectSubsystemModules(Module childMod, java.util.HashMap moduleMap)
Collects all directly dependent subsystems.private static boolean
isBaseModule(Module mod, ModuleInfo mi)
Checks, whether a module is a base module of an given module.private static int
searchModulePosition(PackageSorter.SortModule smodule, java.util.HashMap moduleMap)
Computes the new module position.static void
sort(java.util.List modules)
Sorts the given list of package states.
-
-
-
Method Detail
-
sort
public static void sort(java.util.List modules)
Sorts the given list of package states. The packages are sorted by their dependencies in a way so that all dependent packages are placed on lower positions than the packages which declared the dependency.- Parameters:
modules
- the list of modules.
-
searchModulePosition
private static int searchModulePosition(PackageSorter.SortModule smodule, java.util.HashMap moduleMap)
Computes the new module position. This position is computed according to the dependent modules and subsystems. The returned position will be higher than the highest dependent module position.- Parameters:
smodule
- the sort module for that we compute the new positon.moduleMap
- the map with all modules.- Returns:
- the new positon.
-
isBaseModule
private static boolean isBaseModule(Module mod, ModuleInfo mi)
Checks, whether a module is a base module of an given module.- Parameters:
mod
- the module which to checkmi
- the module info of the suspected base module.- Returns:
- true, if the given module info describes a base module of the given module, false otherwise.
-
collectSubsystemModules
private static java.util.ArrayList collectSubsystemModules(Module childMod, java.util.HashMap moduleMap)
Collects all directly dependent subsystems.- Parameters:
childMod
- the module which to checkmoduleMap
- the map of all other modules, keyed by module class.- Returns:
- the list of all dependent subsystems.
-
-