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

cucumber.runtime.LinePredicate Maven / Gradle / Ivy

There is a newer version: 7.18.1
Show newest version
package cucumber.runtime;

import gherkin.events.PickleEvent;
import gherkin.pickles.PickleLocation;

import java.util.List;
import java.util.Map;

public class LinePredicate implements PicklePredicate {
    private Map> lineFilters;

    public LinePredicate(Map> lineFilters) {
        this.lineFilters = lineFilters;
    }

    @Override
    public boolean apply(PickleEvent pickleEvent) {
        String picklePath = pickleEvent.uri;
        if (!lineFilters.containsKey(picklePath)) {
            return true;
        }
        for (Long line : lineFilters.get(picklePath)) {
            for (PickleLocation location : pickleEvent.pickle.getLocations()) {
                if (line == location.getLine()) {
                    return true;
                }
            }
        }
        return false;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy