li.strolch.search.OrderSearchResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agent Show documentation
Show all versions of agent Show documentation
Strolch Agent which is the runtime for Strolch
The newest version!
package li.strolch.search;
import li.strolch.model.Order;
import li.strolch.model.StrolchElement;
import java.util.Comparator;
import java.util.stream.Stream;
public class OrderSearchResult extends RootElementSearchResult {
public OrderSearchResult(Stream stream) {
super(stream);
}
/**
* Appends a comparator to the stream of elements to compare by date
*
* @return this for chaining
*/
public OrderSearchResult orderByDate() {
return orderByDate(false);
}
/**
* Appends a comparator to the stream of elements to compare by date
*
* @param reversed flag to reverse the comparison
*
* @return this for chaining
*/
public OrderSearchResult orderByDate(boolean reversed) {
Comparator comparator = Comparator.comparing(Order::getDate);
if (reversed)
comparator = comparator.reversed();
this.stream = this.stream.sorted(comparator);
return this;
}
}