Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nullability annotations for better Kotlin support #140

Open
connyduck opened this issue Sep 14, 2022 · 3 comments
Open

Add nullability annotations for better Kotlin support #140

connyduck opened this issue Sep 14, 2022 · 3 comments

Comments

@connyduck
Copy link
Contributor

Motivation

The Kentico Delivery Client and its model are treated as platform types in Kotlin, which makes them harder to use and increases the possibility of accidental NullPointerExceptions.

Proposed solution

All public methods have annotations on parameters and return types so that the Kotlin compiler can correctly infer their nullability and prevent unchecked use of nullable types.
This is also an improvement for Java callers, usually tools emit a warning when nullability is handled the wrong way.

Additional context

Nullability Annotations supported by the Kotlin compiler and more info how calling Java from Kotlin works: https://kotlinlang.org/docs/java-interop.html#nullability-annotations

@Simply007
Copy link
Contributor

Hello @connyduck,

good to see you here again.

Currently, we are migrating to new Kontent.ai services (in this particular case new GitHub organization and Maven package identification).

Once we finish that, I will reach out with the proposal. Do you have a suggestion on which nullability annotation would be the best to use?

@Simply007
Copy link
Contributor

One more question - what are the most important classes you wold like to see the nullability annotation first?

@connyduck
Copy link
Contributor Author

Once we finish that, I will reach out with the proposal. Do you have a suggestion on which nullability annotation would be the best to use?

I don't really care since they all work they same for consumers. org.jetbrains.annotations is probably the most widely used one, and you already have it in StronglyTypedContentItemConverter so that is probably the logical choice.

One more question - what are the most important classes you wold like to see the nullability annotation first?

How about starting with the DeliveryClient itself, then the ContentItem and on to the different elements and assets?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants