org.lambda.query.OrderBy Maven / Gradle / Ivy
package org.lambda.query;
import org.lambda.functions.Function1;
import java.util.Comparator;
public class OrderBy> implements Comparator
{
public static enum Order {
Ascending, Descending
}
private Function1 f1;
private int ascending;
public OrderBy(Function1 f1)
{
this(Order.Ascending, f1);
}
public OrderBy(Order order, Function1 f1)
{
this.f1 = f1;
this.ascending = order == Order.Ascending ? 1 : -1;
}
public static > OrderBy ascending(Function1 f1)
{
return new OrderBy<>(Order.Ascending, f1);
}
public static > OrderBy descending(Function1 f1)
{
return new OrderBy<>(Order.Descending, f1);
}
@Override
public int compare(T a, T b)
{
Comparable
© 2015 - 2024 Weber Informatics LLC | Privacy Policy