Skip to content

Commit c93cbdf

Browse files
dulmandakhfacebook-github-bot
authored andcommittedFeb 9, 2019
Nonnull annotations for native modules (#23353)
Summary: This adds Nonnull annotations for interfaces and classes used for native modules for Android, to improve Kotlin developer experience, but also code quality checks. [Android] [Changed] - Nonnull annotations for native module interfaces Pull Request resolved: #23353 Differential Revision: D14018181 Pulled By: mdvacca fbshipit-source-id: 09a583860a6075e1d6f6df8f479369ae96497133
1 parent d9f34bd commit c93cbdf

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed
 

‎ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import com.facebook.react.uimanager.ViewManager;
1414
import java.util.List;
1515

16+
import javax.annotation.Nonnull;
17+
1618
/**
1719
* Main interface for providing additional capabilities to the catalyst framework by couple of
1820
* different means:
@@ -32,10 +34,10 @@ public interface ReactPackage {
3234
* @param reactContext react application context that can be used to create modules
3335
* @return list of native modules to register with the newly created catalyst instance
3436
*/
35-
List<NativeModule> createNativeModules(ReactApplicationContext reactContext);
37+
List<NativeModule> createNativeModules(@Nonnull ReactApplicationContext reactContext);
3638

3739
/**
3840
* @return a list of view managers that should be registered with {@link UIManagerModule}
3941
*/
40-
List<ViewManager> createViewManagers(ReactApplicationContext reactContext);
42+
List<ViewManager> createViewManagers(@Nonnull ReactApplicationContext reactContext);
4143
}

‎ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import com.facebook.proguard.annotations.DoNotStrip;
1111

12+
import javax.annotation.Nonnull;
13+
1214

1315
/**
1416
* A native module whose API can be provided to JS catalyst instances. {@link NativeModule}s whose
@@ -28,7 +30,7 @@ interface NativeMethod {
2830
* @return the name of this module. This will be the name used to {@code require()} this module
2931
* from javascript.
3032
*/
31-
String getName();
33+
@Nonnull String getName();
3234

3335
/**
3436
* This is called at the end of {@link CatalystApplicationFragment#createCatalystInstance()}

‎ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContextBaseJavaModule.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package com.facebook.react.bridge;
99

10+
import javax.annotation.Nonnull;
1011
import javax.annotation.Nullable;
1112

1213
import android.app.Activity;
@@ -19,7 +20,7 @@ public abstract class ReactContextBaseJavaModule extends BaseJavaModule {
1920

2021
private final ReactApplicationContext mReactApplicationContext;
2122

22-
public ReactContextBaseJavaModule(ReactApplicationContext reactContext) {
23+
public ReactContextBaseJavaModule(@Nonnull ReactApplicationContext reactContext) {
2324
mReactApplicationContext = reactContext;
2425
}
2526

0 commit comments

Comments
 (0)
Please sign in to comment.