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

li.strolch.search.OrderSearchResult Maven / Gradle / Ivy

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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy