hollow
hollow copied to clipboard
Add nullability annotations to generated API
This is particularly useful for Kotlin interop, as it allows the compiler/inspections to infer nullability, but is supported in IntelliJ for several languages:
https://kotlinlang.org/docs/reference/java-interop.html#nullability-annotations
This relates to pull request #286. Supporting deprecation of a field or non-nullability requires some notion of a "modifier" on a hollow field and the ability to map from an annotation on the data model field to such a modifier. A mapping could be declared by the developer so they can use their non-null annotation du-jour.
That'd work perfectly, as Kotlin adds the annotations automatically based on nullability information from the type.
That'd also need to extend to *PrimaryKeyIndex
and similar generated classes.
Re: *PrimaryKeyIndex
can you explain more?
That is, the other place where nullability information would be useful is the generated PrimaryKeyIndexes:
public ModuleDescriptor findMatch(String idOrganization, String idName, String idVersion, String idType) {
int ordinal = idx.getMatchingOrdinal(idOrganization, idName, idVersion, idType);
if(ordinal == -1)
return null;
return api.getModuleDescriptor(ordinal);
}
In this case ModuleDescriptor
is null if a match isn't found.