Skip to content

Add missing nullability annotations to Functions. #601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion firebase-functions/firebase-functions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ plugins {
firebaseLibrary {
testLab.enabled = true
publishSources = true
staticAnalysis.disableKotlinInteropLint()
}

android {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public void onProviderInstallFailed(int i, android.content.Intent intent) {
* @param app The app for the Firebase project.
* @param region The region for the HTTPS trigger, such as "us-central1".
*/
public static FirebaseFunctions getInstance(FirebaseApp app, String region) {
@NonNull
public static FirebaseFunctions getInstance(@NonNull FirebaseApp app, @NonNull String region) {
Preconditions.checkNotNull(app, "You must call FirebaseApp.initializeApp first.");
Preconditions.checkNotNull(region);

Expand All @@ -143,7 +144,8 @@ public static FirebaseFunctions getInstance(FirebaseApp app, String region) {
*
* @param app The app for the Firebase project.
*/
public static FirebaseFunctions getInstance(FirebaseApp app) {
@NonNull
public static FirebaseFunctions getInstance(@NonNull FirebaseApp app) {
return getInstance(app, "us-central1");
}

Expand All @@ -152,17 +154,20 @@ public static FirebaseFunctions getInstance(FirebaseApp app) {
*
* @param region The region for the HTTPS trigger, such as "us-central1".
*/
public static FirebaseFunctions getInstance(String region) {
@NonNull
public static FirebaseFunctions getInstance(@NonNull String region) {
return getInstance(FirebaseApp.getInstance(), region);
}

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

/** Returns a reference to the Callable HTTPS trigger with the given name. */
public HttpsCallableReference getHttpsCallable(String name) {
@NonNull
public HttpsCallableReference getHttpsCallable(@NonNull String name) {
return new HttpsCallableReference(this, name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class HttpsCallableReference {
* @see java.io.IOException
* @see FirebaseFunctionsException
*/
@NonNull
public Task<HttpsCallableResult> call(@Nullable Object data) {
return functionsClient.call(name, data, options);
}
Expand All @@ -94,6 +95,7 @@ public Task<HttpsCallableResult> call(@Nullable Object data) {
*
* @return A Task that will be completed when the HTTPS request has completed.
*/
@NonNull
public Task<HttpsCallableResult> call() {
return functionsClient.call(name, null, options);
}
Expand All @@ -104,11 +106,10 @@ public Task<HttpsCallableResult> call() {
* @param timeout The length of the timeout, in the given units.
* @param units The units for the specified timeout.
*/
public void setTimeout(long timeout, TimeUnit units) {
public void setTimeout(long timeout, @NonNull TimeUnit units) {
options.setTimeout(timeout, units);
}

@NonNull
/**
* Returns the timeout for calls from this instance of Functions.
*
Expand All @@ -124,7 +125,8 @@ public long getTimeout() {
* @param timeout The length of the timeout, in the given units.
* @param units The units for the specified timeout.
*/
public HttpsCallableReference withTimeout(long timeout, TimeUnit units) {
@NonNull
public HttpsCallableReference withTimeout(long timeout, @NonNull TimeUnit units) {
HttpsCallableReference other = new HttpsCallableReference(functionsClient, name);
other.setTimeout(timeout, units);
return other;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.google.firebase.functions;

import androidx.annotation.Nullable;

/** The result of calling a HttpsCallableReference function. */
public class HttpsCallableResult {
// The actual result data, as generic types decoded from JSON.
Expand All @@ -30,6 +32,7 @@ public class HttpsCallableResult {
* array, this object would be a List<Object>. If your trigger returned a JavaScript object with
* keys and values, this object would be a Map<String, Object>.
*/
@Nullable
public Object getData() {
return data;
}
Expand Down