com.bestvike.linq.enumerable.OrderBy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of linq Show documentation
Show all versions of linq Show documentation
LINQ to Objects for Java.
The newest version!
package com.bestvike.linq.enumerable;
import com.bestvike.function.Func1;
import com.bestvike.linq.IEnumerable;
import com.bestvike.linq.IOrderedEnumerable;
import com.bestvike.linq.exception.ExceptionArgument;
import com.bestvike.linq.exception.ThrowHelper;
import java.util.Comparator;
/**
* Created by 许崇雷 on 2018-05-03.
*/
public final class OrderBy {
private OrderBy() {
}
public static IOrderedEnumerable orderBy(IEnumerable source, Func1 keySelector) {
return new OrderedEnumerable<>(source, keySelector, null, false, null);
}
public static IOrderedEnumerable orderBy(IEnumerable source, Func1 keySelector, Comparator comparer) {
return new OrderedEnumerable<>(source, keySelector, comparer, false, null);
}
public static IOrderedEnumerable orderByDescending(IEnumerable source, Func1 keySelector) {
return new OrderedEnumerable<>(source, keySelector, null, true, null);
}
public static IOrderedEnumerable orderByDescending(IEnumerable source, Func1 keySelector, Comparator comparer) {
return new OrderedEnumerable<>(source, keySelector, comparer, true, null);
}
public static IOrderedEnumerable thenBy(IOrderedEnumerable source, Func1 keySelector) {
if (source == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.source);
return source.createOrderedEnumerable(keySelector, null, false);
}
public static IOrderedEnumerable thenBy(IOrderedEnumerable source, Func1 keySelector, Comparator comparer) {
if (source == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.source);
return source.createOrderedEnumerable(keySelector, comparer, false);
}
public static IOrderedEnumerable thenByDescending(IOrderedEnumerable source, Func1 keySelector) {
if (source == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.source);
return source.createOrderedEnumerable(keySelector, null, true);
}
public static IOrderedEnumerable thenByDescending(IOrderedEnumerable source, Func1 keySelector, Comparator comparer) {
if (source == null)
ThrowHelper.throwArgumentNullException(ExceptionArgument.source);
return source.createOrderedEnumerable(keySelector, comparer, true);
}
}