static Comparator<RepositoryResource> byMaxDistance(final Map<String, Integer> maxDistanceMap) {
        return new Comparator<RepositoryResource>() {

            @Override
            public int compare(RepositoryResource o1, RepositoryResource o2) {
                return Integer.compare(getDistance(o2), getDistance(o1));
            }

            private int getDistance(RepositoryResource res) {
                if (res.getType() == ResourceType.FEATURE) {
                    Integer distance = maxDistanceMap.get(((EsaResource) res).getProvideFeature());
                    return distance == null ? 0 : distance;
                } else {
                    return 0;
                }
            }

        };
    }
static Comparator < RepositoryResource > byMaxDistance ( final Map < String , Integer > maxDistanceMap ) { return new Comparator < RepositoryResource > ( ) { @ Override public int compare ( RepositoryResource o1 , RepositoryResource o2 ) { return Integer . compare ( getDistance ( o2 ) , getDistance ( o1 ) ) ; } private int getDistance ( RepositoryResource res ) { if ( res . getType ( ) == ResourceType . FEATURE ) { Integer distance = maxDistanceMap . get ( ( ( EsaResource ) res ) . getProvideFeature ( ) ) ; return distance == null ? 0 : distance ; } else { return 0 ; } } } ; }
Returns a comparator which sorts EsaResources by their values from {@code maxDistanceMap} from greatest to smallest
<p>
Resources whose symbolic names do not appear in the map or which are not EsaResources are assigned a value of zero meaning that they will appear last in a sorted list.

@param maxDistanceMap map from symbolic name to the length of the longest dependency chain from a specific point
@return compariator which sorts based on the maxDistance of resources