Récupérer le premier élément qui correspond à des critères

Comment obtenir le premier élément qui correspond à un des critères dans un cours d'eau? J'ai essayé cela mais ne fonctionne pas

this.stops.stream().filter(Stop s-> s.getStation().getName().equals(name));

Que les critères ne fonctionne pas, le filtre méthode est appelée dans une autre classe que de s'Arrêter.

public class Train {

private final String name;
private final SortedSet<Stop> stops;

public Train(String name) {
    this.name = name;
    this.stops = new TreeSet<Stop>();
}

public void addStop(Stop stop) {
    this.stops.add(stop);
}

public Stop getFirstStation() {
    return this.getStops().first();
}

public Stop getLastStation() {
    return this.getStops().last();
}

public SortedSet<Stop> getStops() {
    return stops;
}

public SortedSet<Stop> getStopsAfter(String name) {


    //return this.stops.subSet(, toElement);
    return null;
}
}


import java.util.ArrayList;
import java.util.List;

public class Station {
private final String name;
private final List<Stop> stops;

public Station(String name) {
    this.name = name;
    this.stops = new ArrayList<Stop>();

}

public String getName() {
    return name;
}

}
InformationsquelleAutor user2147674 | 2014-04-08