Package org.apache.ivy.core.sort
Class ModuleInSort
- java.lang.Object
-
- org.apache.ivy.core.sort.ModuleInSort
-
class ModuleInSort extends java.lang.Object
Decorates a ModuleDescriptor with some attributes used during the sort. Thus every instance of a ModuleInSort can be used in only one ModuleDescriptorSorter at a time.The added fields are:
isSorted
: is true if and only if this module has already been added to the sorted list.loopElements
: When the module is the root of a loop (=the first element of a loop met during the sort),loopElements
contains all ModuleInSort of the loop (excluding the root itself.isLoopIntermediateElement
: When a loop is detected, all modules included in the loop (except the root) haveisLoopIntermediateElement
set to true.caller
: During the sort, we traverse recursively the graph. When doing that, caller point to the parent element.
-
-
Field Summary
Fields Modifier and Type Field Description private ModuleInSort
caller
private boolean
isLoopIntermediateElement
private boolean
isSorted
private java.util.List<ModuleInSort>
loopElements
private ModuleDescriptor
module
-
Constructor Summary
Constructors Constructor Description ModuleInSort(ModuleDescriptor moduleToSort)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToSortedListIfRequired(java.util.List<ModuleDescriptor> sorted)
Add this module to the sorted list except if this module is an intermediary element of a loop.private void
addToSortList(java.util.List<ModuleDescriptor> sortedList)
Add this module to the sorted list.boolean
checkLoop(ModuleInSort futurCaller, CircularDependencyStrategy depStrategy)
Check if a adding this element as a dependency of caller will introduce a circular dependency.void
endOfCall()
DependencyDescriptor[]
getDependencies()
ModuleDescriptor
getSortedModuleDescriptor()
boolean
isInLoop()
boolean
isProcessed()
This ModuleInSort has already been analyzed.boolean
isSorted()
This ModuleInSort has been placed on the sorted liststatic void
logLoopWarning(java.util.List<ModuleDescriptor> loopElement)
Log a warning saying that a loop is detectedboolean
match(DependencyDescriptor descriptor, VersionMatcher versionMatcher)
Return true if this module match the DependencyDescriptor with the given versionMatcher.void
setCaller(ModuleInSort caller)
java.lang.String
toString()
-
-
-
Field Detail
-
module
private final ModuleDescriptor module
-
isSorted
private boolean isSorted
-
loopElements
private java.util.List<ModuleInSort> loopElements
-
isLoopIntermediateElement
private boolean isLoopIntermediateElement
-
caller
private ModuleInSort caller
-
-
Constructor Detail
-
ModuleInSort
public ModuleInSort(ModuleDescriptor moduleToSort)
-
-
Method Detail
-
isInLoop
public boolean isInLoop()
-
isSorted
public boolean isSorted()
This ModuleInSort has been placed on the sorted list
-
isProcessed
public boolean isProcessed()
This ModuleInSort has already been analyzed. It is either already added to the sorted list, either it is included in a loop and will be added when the root of the loop will be added to the list.
-
setCaller
public void setCaller(ModuleInSort caller)
-
endOfCall
public void endOfCall()
-
checkLoop
public boolean checkLoop(ModuleInSort futurCaller, CircularDependencyStrategy depStrategy)
Check if a adding this element as a dependency of caller will introduce a circular dependency. If it is, all the elements of the loop are flagged as 'loopIntermediateElement', and the loopElements of this module (which is the root of the loop) is updated. The depStrategy is invoked on order to report a correct circular loop message.- Parameters:
futurCaller
- ModuleInSortdepStrategy
- CircularDependencyStrategy- Returns:
- true if a loop is detected.
-
addToSortedListIfRequired
public void addToSortedListIfRequired(java.util.List<ModuleDescriptor> sorted)
Add this module to the sorted list except if this module is an intermediary element of a loop. If this module is the 'root' of a loop, then all elements of that loops are added before.- Parameters:
sorted
- The list of sorted elements on which this module will be added
-
addToSortList
private void addToSortList(java.util.List<ModuleDescriptor> sortedList)
Add this module to the sorted list. If current is the 'root' of a loop, then all elements of that loops are added before.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getDependencies
public DependencyDescriptor[] getDependencies()
-
logLoopWarning
public static void logLoopWarning(java.util.List<ModuleDescriptor> loopElement)
Log a warning saying that a loop is detected
-
match
public boolean match(DependencyDescriptor descriptor, VersionMatcher versionMatcher)
Return true if this module match the DependencyDescriptor with the given versionMatcher. If this module has no version defined, then true is always returned.
-
getSortedModuleDescriptor
public ModuleDescriptor getSortedModuleDescriptor()
-
-