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:16:24 -08:00
committed by Facebook Github Bot
parent d002d30325
commit b640b6faf7
10 changed files with 114 additions and 88 deletions
@@ -9,23 +9,26 @@ package com.facebook.react.bridge;
import java.util.HashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Interface for a map that allows typed access to its members. Used to pass parameters from JS to
* Java.
*/
public interface ReadableMap {
boolean hasKey(String name);
boolean isNull(String name);
boolean getBoolean(String name);
double getDouble(String name);
int getInt(String name);
String getString(String name);
ReadableArray getArray(String name);
ReadableMap getMap(String name);
Dynamic getDynamic(String name);
ReadableType getType(String name);
ReadableMapKeySetIterator keySetIterator();
HashMap<String, Object> toHashMap();
boolean hasKey(@Nonnull String name);
boolean isNull(@Nonnull String name);
boolean getBoolean(@Nonnull String name);
double getDouble(@Nonnull String name);
int getInt(@Nonnull String name);
@Nullable String getString(@Nonnull String name);
@Nullable ReadableArray getArray(@Nonnull String name);
@Nullable ReadableMap getMap(@Nonnull String name);
@Nonnull Dynamic getDynamic(@Nonnull String name);
@Nonnull ReadableType getType(@Nonnull String name);
@Nonnull ReadableMapKeySetIterator keySetIterator();
@Nonnull HashMap<String, Object> toHashMap();
}