Feature Overview
This feature guards that method parameters cannot be null.
This feature guards that method parameters cannot be null.
None
public class NotNullDemo {
public static Integer add(
@notNull Integer a,
Integer b!
) {
return a + b;
}
}
public class NotNullDemo {
public static Integer add(Integer a, Integer b) {
Sweet.assertNotNull(a, '"a" in NotNullDemo.add(Integer, Integer) should not be null');
Sweet.assertNotNull(b, '"b" in NotNullDemo.add(Integer, Integer) should not be null');
return a + b;
}
}
@notNull
can only be used on method parameters.
Or you can append !
after the parameter variable.
Contribute on Github! Edit this section.