com.github.paganini2008.devtools.beans.streaming.Orders Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of devtools-beans-streaming Show documentation
Show all versions of devtools-beans-streaming Show documentation
a useful java tools based on java collection stream framework
package com.github.paganini2008.devtools.beans.streaming;
import java.util.function.Function;
/**
*
* Orders
*
* @author Fred Feng
*
* @version 1.0
*/
public abstract class Orders {
public static > Sort descending(final String attributeName, final Class requiredType) {
return descending(Property.forName(attributeName, requiredType));
}
public static > Sort ascending(final String attributeName, final Class requiredType) {
return ascending(Property.forName(attributeName, requiredType));
}
public static > Sort descending(final Function function) {
BeanSort sort = new BeanSort();
sort.descending(function);
return sort;
}
public static > Sort ascending(final Function function) {
BeanSort sort = new BeanSort();
sort.ascending(function);
return sort;
}
public static > Sort> groupAscending(final String attributeName, final Class requiredType) {
return groupAscending(group -> {
return MappedBy.forName(attributeName, requiredType).apply(group.getAttributes());
});
}
public static > Sort> groupDescending(final String attributeName, final Class requiredType) {
return groupDescending(group -> {
return MappedBy.forName(attributeName, requiredType).apply(group.getAttributes());
});
}
public static > Sort> groupDescending(final GroupFunction function) {
BeanSort> sort = new BeanSort>();
sort.descending(function);
return sort;
}
public static > Sort> groupAscending(final GroupFunction function) {
BeanSort> sort = new BeanSort>();
sort.ascending(function);
return sort;
}
}