Is there a possibility to mark list in Java as containing not null values.
An example, I can mark getter, as returning not-nulls:
@NullableByDefault
static class Abra {
@Nonnull
public List<String> getList() {
return Arrays.asList("A", "B", "C");
}
}
but then
val list = Abra().list
val a = list.first()
list itself is non-null, but a is nullable in kotlin.
I know, that generics are erased in java byte code,
but maybe some tricks exists, like special annotation on list.
My use case:
I add Nonnull annotation on fields while generating Java classes from xsd (jaxb plugin) when those elements are required by xsd.
Later on I use those classes from kotlin.