use of com.ecwid.consul.v1.event.model.Event in project spring-cloud-consul by spring-cloud.
the class EventService method filterEvents.
/**
* from https://github.com/hashicorp/consul/blob/master/watch/funcs.go#L169-L194 .
* @param toFilter events to filter
* @param lastIndex last index to pick from the list of events
* @return filtered list of events
*/
protected List<Event> filterEvents(List<Event> toFilter, Long lastIndex) {
List<Event> events = toFilter;
if (lastIndex != null) {
for (int i = 0; i < events.size(); i++) {
Event event = events.get(i);
Long eventIndex = event.getWaitIndex();
if (lastIndex.equals(eventIndex)) {
events = events.subList(i + 1, events.size());
break;
}
}
}
return events;
}
Aggregations