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

netflix.nebula.dependency.recommender.provider.MapRecommendationProvider Maven / Gradle / Ivy

Go to download

Allows projects to leave off version numbers in dependencies section and have versions recommended by other sources

There is a newer version: 12.5.1
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy