All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.prezi.pride.ivyversions.SubVersionMatcher Maven / Gradle / Ivy

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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy