Closed ashenriques closed 4 years ago
Adding those annotations is a great idea.
Sadly due to time constraints, I cannot tell you anything about the timeline when this might happen in the SDK.
Sofar, please treat any responses from the SDK as nullable
.
Will take that into the consideration when implementing new code. Unfortunately, there is no plan for now to refactor current codebase.
all the fields that might return a "null" value, should be annotated as such.
For instance, on the class "FetchQuery" the method "first" should use the annotation.
Otherwise this code crashes in Kotlin:
fun getExampleByID(exampleID: String) = vault.fetch(ExampleCF::class.java).where("${
ExampleCF$Fields.REMOTE_ID} = \"$exampleID\"").first()
fun doSomethingWithExample(example: ExampleCF) : String = example.toString()
fun causeCrash() = doSomethingWithExample(getExampleByID("non existing id"))
since Kotlin is not expecting that getExampleByID might in any case return a null value, when the ID doesn't exist and that's what vault actually returns, Kotlin will try to cast a null to a non-null object causing a crash