Created
July 21, 2015 05:22
-
-
Save Unh0lyTigg/34df51afadc4da7e6e3e to your computer and use it in GitHub Desktop.
ClassFinderSorter segment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int compare(ClassFinder cf1, ClassFinder cf2) { | |
String targetClass1 = cf1.getTargetClass(); | |
String targetClass2 = cf2.getTargetClass(); | |
List<String> prereq1 = cf1.classesThatNeedFindingFirst(); | |
List<String> prereq2 = cf2.classesThatNeedFindingFirst(); | |
if (prereq1.isEmpty() && !prereq2.isEmpty()) | |
return -1; | |
if (prereq2.isEmpty() && !prereq1.isEmpty()) | |
return 1; | |
if (prereq1.isEmpty() && prereq2.isEmpty()) | |
return 0; | |
if (prereq1.contains(targetClass2)) | |
return 1; | |
if (prereq2.contains(targetClass1)) | |
return -1; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment