hollow icon indicating copy to clipboard operation
hollow copied to clipboard

Add nullability annotations to generated API

Open DanielThomas opened this issue 6 years ago • 4 comments

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

DanielThomas avatar Oct 23 '18 21:10 DanielThomas

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.

PaulSandoz avatar Oct 25 '18 15:10 PaulSandoz

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.

DanielThomas avatar Oct 25 '18 16:10 DanielThomas

Re: *PrimaryKeyIndex can you explain more?

PaulSandoz avatar Oct 25 '18 17:10 PaulSandoz

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.

DanielThomas avatar Oct 25 '18 21:10 DanielThomas