com.github.methylene.args.predicate.IntegerPredicates Maven / Gradle / Ivy
The newest version!
package com.github.methylene.args.predicate;
import com.github.methylene.args.Predicate;
public class IntegerPredicates {
public static Predicate even() {
return new Predicate() {
@Override
public boolean matches(Integer arg) {
return arg != null && arg % 2 == 0;
}
};
}
public static Predicate odd() {
return new Predicate() {
@Override
public boolean matches(Integer arg) {
return arg != null && arg % 2 != 0;
}
};
}
public static Predicate exactly(int n) {
return Predicates.is(n);
}
public static Predicate geq(final int n) {
return new Predicate() {
@Override
public boolean matches(Integer arg) {
return arg != null && arg >= n;
}
};
}
public static Predicate leq(final int n) {
return new Predicate() {
@Override
public boolean matches(Integer arg) {
return arg != null && arg <= n;
}
};
}
}