com.github.paganini2008.devtools.beans.streaming.Having 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.Predicate;
import com.github.paganini2008.devtools.Comparables;
/**
*
* Having
*
* @author Fred Feng
*
* @version 1.0
*/
public abstract class Having {
public static > Predicate> eq(Calculation calculation, T value) {
return group -> {
T result = group.summarize(calculation);
return Comparables.eq(result, value);
};
}
public static > Predicate> ne(Calculation calculation, T value) {
return group -> {
T result = group.summarize(calculation);
return Comparables.ne(result, value);
};
}
public static > Predicate> between(Calculation calculation, T minValue, T maxValue) {
return group -> {
T result = group.summarize(calculation);
return Comparables.gte(result, minValue) && Comparables.lte(result, maxValue);
};
}
public static > Predicate> lt(Calculation calculation, T value) {
return group -> {
T result = group.summarize(calculation);
return Comparables.lt(result, value);
};
}
public static > Predicate> lte(Calculation calculation, T value) {
return group -> {
T result = group.summarize(calculation);
return Comparables.lte(result, value);
};
}
public static > Predicate> gt(Calculation calculation, T value) {
return group -> {
T result = group.summarize(calculation);
return Comparables.gt(result, value);
};
}
public static > Predicate> gte(Calculation calculation, T value) {
return group -> {
T result = group.summarize(calculation);
return Comparables.gte(result, value);
};
}
}