| 1 6 package fr.jayasoft.ivy.latest; 7 8 import java.util.Comparator ; 9 10 import fr.jayasoft.ivy.ArtifactInfo; 11 12 13 public class LatestLexicographicStrategy extends ComparatorLatestStrategy { 14 22 private static Comparator COMPARATOR = new Comparator () { 23 public int compare(Object o1, Object o2) { 24 String rev1 = ((ArtifactInfo)o1).getRevision(); 25 String rev2 = ((ArtifactInfo)o2).getRevision(); 26 if (rev1.startsWith("latest")) { 27 return 1; 28 } 29 if (rev1.endsWith("+") && rev2.startsWith(rev1.substring(0, rev1.length() - 1))) { 30 return 1; 31 } 32 if (rev2.startsWith("latest")) { 33 return -1; 34 } 35 if (rev2.endsWith("+") && rev1.startsWith(rev2.substring(0, rev2.length() - 1))) { 36 return -1; 37 } 38 return rev1.compareTo(rev2); 39 } 40 41 }; 42 43 public LatestLexicographicStrategy() { 44 super(COMPARATOR); 45 setName("latest-lexico"); 46 } 47 48 } 49 | Popular Tags |