Generic predicate in Java 8
Even though Number doesn't provide any methods to check for divisibility directly, it does provide a method to make the Number into a double, and as we all know, doubles do support the % operator.

Other slight modifications:


Your method can be static
You don't need to specify the (T dividend) -&gt;, simply using dividend -&gt; is enough.


Final:

public static &lt;T extends Number&gt; Predicate&lt;T&gt; isDivisibleBy(T divisor) {
    return dividend -&gt; dividend.doubleValue() % divisor.doubleValue() == 0;
}


I have tested this code for many cases using a for-loop, and it works mostly fine.

I had one problem with using Long though as the Long value = -195798407404780179L was converted into -1.95798407404780192E17, which loses some accuracy. So it seems like you need a special case for Long:

public static Predicate&lt;Long&gt; isDivisibleBy(Long divisor) {
    return dividend -&gt; dividend % divisor == 0;
}


However, be aware that there are some primitive variants available for Predicate:


IntPredicate
LongPredicate
DoublePredicate