Skip to content

Commit e7ffa75

Browse files
authored
Add missing nullability annotations to Functions. (#601)
1 parent b543101 commit e7ffa75

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

firebase-functions/firebase-functions.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ plugins {
1919
firebaseLibrary {
2020
testLab.enabled = true
2121
publishSources = true
22-
staticAnalysis.disableKotlinInteropLint()
2322
}
2423

2524
android {

firebase-functions/src/main/java/com/google/firebase/functions/FirebaseFunctions.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ public void onProviderInstallFailed(int i, android.content.Intent intent) {
128128
* @param app The app for the Firebase project.
129129
* @param region The region for the HTTPS trigger, such as "us-central1".
130130
*/
131-
public static FirebaseFunctions getInstance(FirebaseApp app, String region) {
131+
@NonNull
132+
public static FirebaseFunctions getInstance(@NonNull FirebaseApp app, @NonNull String region) {
132133
Preconditions.checkNotNull(app, "You must call FirebaseApp.initializeApp first.");
133134
Preconditions.checkNotNull(region);
134135

@@ -143,7 +144,8 @@ public static FirebaseFunctions getInstance(FirebaseApp app, String region) {
143144
*
144145
* @param app The app for the Firebase project.
145146
*/
146-
public static FirebaseFunctions getInstance(FirebaseApp app) {
147+
@NonNull
148+
public static FirebaseFunctions getInstance(@NonNull FirebaseApp app) {
147149
return getInstance(app, "us-central1");
148150
}
149151

@@ -152,17 +154,20 @@ public static FirebaseFunctions getInstance(FirebaseApp app) {
152154
*
153155
* @param region The region for the HTTPS trigger, such as "us-central1".
154156
*/
155-
public static FirebaseFunctions getInstance(String region) {
157+
@NonNull
158+
public static FirebaseFunctions getInstance(@NonNull String region) {
156159
return getInstance(FirebaseApp.getInstance(), region);
157160
}
158161

159162
/** Creates a Cloud Functions client with the default app. */
163+
@NonNull
160164
public static FirebaseFunctions getInstance() {
161165
return getInstance(FirebaseApp.getInstance(), "us-central1");
162166
}
163167

164168
/** Returns a reference to the Callable HTTPS trigger with the given name. */
165-
public HttpsCallableReference getHttpsCallable(String name) {
169+
@NonNull
170+
public HttpsCallableReference getHttpsCallable(@NonNull String name) {
166171
return new HttpsCallableReference(this, name);
167172
}
168173

firebase-functions/src/main/java/com/google/firebase/functions/HttpsCallableReference.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public class HttpsCallableReference {
7676
* @see java.io.IOException
7777
* @see FirebaseFunctionsException
7878
*/
79+
@NonNull
7980
public Task<HttpsCallableResult> call(@Nullable Object data) {
8081
return functionsClient.call(name, data, options);
8182
}
@@ -94,6 +95,7 @@ public Task<HttpsCallableResult> call(@Nullable Object data) {
9495
*
9596
* @return A Task that will be completed when the HTTPS request has completed.
9697
*/
98+
@NonNull
9799
public Task<HttpsCallableResult> call() {
98100
return functionsClient.call(name, null, options);
99101
}
@@ -104,11 +106,10 @@ public Task<HttpsCallableResult> call() {
104106
* @param timeout The length of the timeout, in the given units.
105107
* @param units The units for the specified timeout.
106108
*/
107-
public void setTimeout(long timeout, TimeUnit units) {
109+
public void setTimeout(long timeout, @NonNull TimeUnit units) {
108110
options.setTimeout(timeout, units);
109111
}
110112

111-
@NonNull
112113
/**
113114
* Returns the timeout for calls from this instance of Functions.
114115
*
@@ -124,7 +125,8 @@ public long getTimeout() {
124125
* @param timeout The length of the timeout, in the given units.
125126
* @param units The units for the specified timeout.
126127
*/
127-
public HttpsCallableReference withTimeout(long timeout, TimeUnit units) {
128+
@NonNull
129+
public HttpsCallableReference withTimeout(long timeout, @NonNull TimeUnit units) {
128130
HttpsCallableReference other = new HttpsCallableReference(functionsClient, name);
129131
other.setTimeout(timeout, units);
130132
return other;

firebase-functions/src/main/java/com/google/firebase/functions/HttpsCallableResult.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.google.firebase.functions;
1616

17+
import androidx.annotation.Nullable;
18+
1719
/** The result of calling a HttpsCallableReference function. */
1820
public class HttpsCallableResult {
1921
// The actual result data, as generic types decoded from JSON.
@@ -30,6 +32,7 @@ public class HttpsCallableResult {
3032
* array, this object would be a List<Object>. If your trigger returned a JavaScript object with
3133
* keys and values, this object would be a Map<String, Object>.
3234
*/
35+
@Nullable
3336
public Object getData() {
3437
return data;
3538
}

0 commit comments

Comments
 (0)