com.prezi.pride.ivyversions.SubVersionMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-pride-plugin Show documentation
Show all versions of gradle-pride-plugin Show documentation
Pride manages multiple Gradle modules as a single Gradle project
The newest version!
package com.prezi.pride.ivyversions;
import java.util.Comparator;
/**
* Version matcher for dynamic version selectors ending in '+'.
*/
public class SubVersionMatcher implements VersionMatcher {
private final Comparator staticVersionComparator;
public SubVersionMatcher(VersionMatcher staticVersionComparator) {
this.staticVersionComparator = staticVersionComparator;
}
public boolean canHandle(String selector) {
return selector.endsWith("+");
}
public boolean accept(String selector, String candidate) {
String prefix = selector.substring(0, selector.length() - 1);
return candidate.startsWith(prefix);
}
public int compare(String selector, String candidate) {
if (accept(selector, candidate)) {
return 1;
}
return staticVersionComparator.compare(selector, candidate);
}
}