Skip to content

Add Jetbrains nullability annotations to POJO classes #717

@tbcrawford

Description

@tbcrawford

Checklist

  • I have looked into the Readme and Examples, and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

When interfacing with the POJO classes from Kotlin we end up with platform types.

In short, platform types are a type that comes from another language (Java) that has unknown nullability. This can be problematic for Kotlin because some field that we assume to not be null can be null and lead to NullPointerExceptions. Adding nullable annotations should be useful for any JVM language interfacing with this library.

Describe the ideal solution

Add @Nullable and @NotNull annotations to all POJO classes and types publicly exposed.

Alternatives and current workarounds

The more dangerous alternative is to assume the nullability of a type and effectively cast it to that type in Kotlin, but we end up with typed fields all over the place which become unnecessary.

Something like:

val user = User() // assume this is `com.auth0.json.mgmt.users.User` that has values
val name: String = user.name // This will call user.getName() in Java and effectively cast it as not nullable, which is incorrect

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA feature has been asked for or suggested by the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions