Class PackageSorter

java.lang.Object
org.jfree.base.modules.PackageSorter

public final class PackageSorter extends 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.

  • Constructor Details

    • PackageSorter

      private PackageSorter()
      DefaultConstructor.
  • Method Details

    • sort

      public static void sort(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, 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 check
      mi - 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 ArrayList collectSubsystemModules(Module childMod, HashMap moduleMap)
      Collects all directly dependent subsystems.
      Parameters:
      childMod - the module which to check
      moduleMap - the map of all other modules, keyed by module class.
      Returns:
      the list of all dependent subsystems.