Class PackageSorter.SortModule

  • All Implemented Interfaces:
    java.lang.Comparable
    Enclosing class:
    PackageSorter

    private static class PackageSorter.SortModule
    extends java.lang.Object
    implements java.lang.Comparable
    An Internal wrapper class which collects additional information on the given module. Every module has a position, which is heigher than the position of all dependent modules.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.ArrayList dependSubsystems
      A list of all directly dependent subsystems.
      private int position
      stores the relative position of the module in the global list.
      private PackageState state
      The package state of the to be matched module.
    • Constructor Summary

      Constructors 
      Constructor Description
      SortModule​(PackageState state)
      Creates a new SortModule for the given package state.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(java.lang.Object o)
      Compares this module against an other sort module.
      java.util.ArrayList getDependSubsystems()
      Returns the list of all dependent subsystems.
      int getPosition()
      Returns the current position of this module in the global list.
      PackageState getState()
      Returns the package state contained in this SortModule.
      void setDependSubsystems​(java.util.ArrayList dependSubsystems)
      Defines a list of dependent subsystems for this module.
      void setPosition​(int position)
      Defines the position of this module in the global list of all known modules.
      java.lang.String toString()
      Returns a basic string representation of this SortModule.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • position

        private int position
        stores the relative position of the module in the global list.
      • state

        private final PackageState state
        The package state of the to be matched module.
      • dependSubsystems

        private java.util.ArrayList dependSubsystems
        A list of all directly dependent subsystems.
    • Constructor Detail

      • SortModule

        public SortModule​(PackageState state)
        Creates a new SortModule for the given package state.
        Parameters:
        state - the package state object, that should be wrapped up by this class.
    • Method Detail

      • getDependSubsystems

        public java.util.ArrayList getDependSubsystems()
        Returns the list of all dependent subsystems. The list gets defined when the sorting is started.
        Returns:
        the list of all dependent subsystems.
      • setDependSubsystems

        public void setDependSubsystems​(java.util.ArrayList dependSubsystems)
        Defines a list of dependent subsystems for this module. The list contains the names of the dependent subsystems as strings.
        Parameters:
        dependSubsystems - a list of all dependent subsystems.
      • getPosition

        public int getPosition()
        Returns the current position of this module in the global list. The position is computed by comparing all positions of all dependent subsystem modules.
        Returns:
        the current module position.
      • setPosition

        public void setPosition​(int position)
        Defines the position of this module in the global list of all known modules.
        Parameters:
        position - the position.
      • getState

        public PackageState getState()
        Returns the package state contained in this SortModule.
        Returns:
        the package state of this module.
      • toString

        public java.lang.String toString()
        Returns a basic string representation of this SortModule. This should be used for debugging purposes only.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this module.
        See Also:
        Object.toString()
      • compareTo

        public int compareTo​(java.lang.Object o)
        Compares this module against an other sort module.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        o - the other sort module instance.
        Returns:
        -1 if the other's module position is less than this modules position, +1 if this module is less than the other module or 0 if both modules have an equal position in the list.
        See Also:
        Comparable.compareTo(java.lang.Object)