applibgroup / HarmonyOS-Knowledgebase

This repository contains code samples of HarmonyOS Training
Apache License 2.0
17 stars 6 forks source link

What is the alternative in Harmony OS for Nullable and NonNull annotations? #41

Closed shekhar-amit closed 3 years ago

shekhar-amit commented 3 years ago

Describe the query

There are many arguments in my code which can take the value null. It would be helpful if there is a @Nullable and @NonNull annotation like the ones offered in Android via Annotation.

Is there an alternative available in Harmony OS?

Create the query with harmonyos tag in stackoverflow and share the link here:

**** https://stackoverflow.com/questions/68589085/what-is-the-alternative-in-harmony-os-for-nullable-and-nonnull-annotations

Additional information

Developer Platform: Windows DevEco Studio version: 2.1.0.303 SDK API version: 5 SDK version: 2.1.1.21 Device: Not required
Device OS version: Not required

GowthamRayar commented 3 years ago

You can use org.jetbrains.annotations.Nullable & org.jetbrains.annotations.NotNull annotations available from jetbrains dependency,

implementation 'org.jetbrains:annotations:20.1.0'