I have a class with an overloaded Method. I want it to either take a lambda function OR a Number which is comparable (as I have to check values of the method)
public class Factory {
public static LambdaHandler create(Runnable fn){
return new LambdaHandler(fn);
}
public static <T extends Number & Comparable<T>> NumberHandler create(T number){
return new NumberHandler<>(number);
}
}
However when I try to call these methods in another class I am getting an ambiguous match error.
@Test
public void testSomething() throws Exception {
create(() -> { }).handle();
}
Any ideas how to fix this?
Cheers,
Ben