I have two questions.
A) Need some code review on my thinking process (2 stages). What could I have done better at each stage, were there alternative things I could have done?
1. First attempt at Generics with numbers:
```
@FunctionalInterface
public interface NumberPredicate<T extends Number> {
boolean test(T number);
}
public class NumberUtils {
public static NumberPredicate isEven = x -> {
if(x instanceof Double || x instanceof Float || x instanceof BigDecimal){
BigDecimal num = BigDecimal.valueOf(0);
if(x instanceof Double)
num = BigDecimal.valueOf((Double)x);
else if (x instanceof Float)
num = BigDecimal.valueOf((Float)x);
else if (x instanceof BigDecimal)
num = (BigDecimal) x;
return num.stripTrailingZeros().scale()<=0;
}
return (x.intValue() % 2 ==0);
};
}
```
2. Second attempt at Generics with numbers:
```
@FunctionalInterface
public interface NumberPredicate<T extends Number> {
boolean test(T number);
}
public class NumberUtils {
public static NumberPredicate<Integer> isEvenInt = x -> x % 2 ==0;
public static NumberPredicate<Double> isEvenDouble = x -> {
while(x % 1 != 0)
x*=10;
return x % 2 == 0;
};
//assume i will implement a new method per number type
}
```
B) For my second question. When I call my method:
```
List<Integer> nums = Arrays.asList(1,2,3,4,5,6,7,8,9,10);
nums.stream().filter(NumberUtils.isEvenInt::test).collect(Collectors.toList()).forEach(System.out::println);
```
Why does it need to be called with `NumberUtils.isEvenInt::test` and not `NumberUtils.isEvenInt`?