I have two methods that in some cases have ambiguous call. For example:
void bla(Integer a);
void bla(String a);
Basically when I call bla(null) I will get ambiguous call error. Is it possible to write or use some annotation that will solve this issue before the compiler phase?
Can I block a null option from in bla(String a)
before the compiler kicks in? I tried to wrote a NotNull annotation (but it kicks in after the compile phase).
See code below:
@Documented
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
public @interface NotNull1 {
String value() default "";
}
void bla(@NotNull1 String a);
Cast null to the type of the parameter of the method.
bla((Integer) null);
bla((String) null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With