nullable annotations to ReadableMap, WritableMap, ReadableArray, Writable. (#23329)

Summary:
Kotlin is getting traction and more developers write RN native modules in it. This PR adds nullable annotations to help with Kotlin null inference and improve developer experience. Also it'll help checking code quality using lint.

I skimmed through JavaOnlyMap.java, JavaOnlyArray.java, ReadableNativeArray.java, ReadableNativeMap.java, WritableNativeArray.java and WritableNativeMap.java to infer nullability.

This is breaking change to Kotlin code.

[Android] [Changed] - Add nullable annotations to ReadableMap, WritableMap, ReadableArray, Writable.
Pull Request resolved: https://github.com/facebook/react-native/pull/23329

Differential Revision: D14002571

Pulled By: cpojer

fbshipit-source-id: 899d8b3b0a5dad43e8300e6c4ea4208cca0f01a9
This commit is contained in:
Dulmandakh
2019-02-08 04:08:37 -08:00
committed by Facebook Github Bot
parent d002d30325
commit b640b6faf7
10 changed files with 114 additions and 88 deletions
@@ -9,6 +9,9 @@ package com.facebook.react.bridge;
import java.util.ArrayList;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Interface for an array that allows typed access to its members. Used to pass parameters from JS
* to Java.
@@ -20,11 +23,11 @@ public interface ReadableArray {
boolean getBoolean(int index);
double getDouble(int index);
int getInt(int index);
String getString(int index);
ReadableArray getArray(int index);
ReadableMap getMap(int index);
Dynamic getDynamic(int index);
ReadableType getType(int index);
ArrayList<Object> toArrayList();
@Nullable String getString(int index);
@Nullable ReadableArray getArray(int index);
@Nullable ReadableMap getMap(int index);
@Nonnull Dynamic getDynamic(int index);
@Nonnull ReadableType getType(int index);
@Nonnull ArrayList<Object> toArrayList();
}