netflix.nebula.dependency.recommender.provider.MapRecommendationProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nebula-dependency-recommender Show documentation
Show all versions of nebula-dependency-recommender Show documentation
Allows projects to leave off version numbers in dependencies section and have versions recommended by other sources
package netflix.nebula.dependency.recommender.provider;
import org.gradle.api.InvalidUserDataException;
import java.util.Collection;
import java.util.Map;
public class MapRecommendationProvider extends AbstractRecommendationProvider {
private Map recommendations;
private FuzzyVersionResolver fuzzyResolver = new FuzzyVersionResolver() {
@Override
protected Collection propertyNames() {
return recommendations.keySet();
}
@Override
protected String propertyValue(String name) {
return recommendations.get(name);
}
};
@Override
public String getVersion(String org, String name) {
if(recommendations == null)
throw new InvalidUserDataException("No recommender of dependencies to versions was provided");
return fuzzyResolver.versionOf(org + ":" + name);
}
public void setRecommendations(Map recommendations) {
this.recommendations = recommendations;
}
}