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

org.opentripplanner.routing.algorithm.filterchain.ItineraryFilter Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.routing.algorithm.filterchain;

import org.opentripplanner.model.plan.Itinerary;

import java.util.List;

/**
 * Filter or decorate itineraries. A filter can modify the elements in the list, but not the List. 
 * It should treat the list as immutable. Do not change the list passed into the filter, instead
 * make a copy, change it and return the copy. It is allowed to return the list unchanged.
 * 

* A filter should do only one thing! For example do not change the itineraries and delete elements * in the same filter. Instead create two filters and insert them after each other in the filter * chain. *

* This allows decoration of each filter and make it easier to reuse logic. Like the * {@link org.opentripplanner.routing.algorithm.filterchain.filters.MaxLimitFilter} is reused in * several places. */ public interface ItineraryFilter { /** * A name used for debugging the filter chain. *

* Use '-' so separate words like: {@code sort-on-duration-filter} */ String name(); /** * Process the given itineraries returning the result. *

* This function should not change the List instance passed in, but may change the elements. It * can return a List with a subset of the elements (or even different, new elements). Note! that * the list passed into the filter might be immutable. *

* This can be achieved using streams. Example: *

     * return itineraries.stream().filter(...).collect(Collectors.toList());
     * 
*/ List filter(List itineraries); /** * Return {@code true} if the filter removes itineraries from the input list * in the {@link #filter(List)} method, or {@code false} if no itineraries are * deleted. Filters that sort the list or chane the itineraries should return * {@code false}. *

* This is used by the debug functionality, each */ boolean removeItineraries(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy