All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.firebase.tasks.Continuation Maven / Gradle / Ivy

Go to download

This is the official Firebase Admin Java SDK. Build extraordinary native JVM apps in minutes with Firebase. The Firebase platform can power your app’s backend, user authentication, static hosting, and more.

There is a newer version: 9.3.0
Show newest version
/*
 * Copyright 2017 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.firebase.tasks;

import com.google.firebase.internal.NonNull;

/**
 * A function that is called to continue execution after completion of a {@link Task}.
 *
 * @param  the Task's result type
 * @param  the Continuation's result type
 * @see Task#continueWith(Continuation)
 * @see Task#continueWithTask(Continuation)
 */
public interface Continuation {

  /**
   * Returns the result of applying this Continuation to {@code task}.
   *
   * 

To propagate failure from the completed Task call {@link Task#getResult()} and allow the * {@link RuntimeExecutionException} to propagate. The RuntimeExecutionException will be unwrapped * such that the Task returned by {@link Task#continueWith(Continuation)} or {@link * Task#continueWithTask(Continuation)} fails with the original exception. * *

To suppress specific failures call {@link Task#getResult(Class)} and catch the exception * types of interest: * *

   * task.continueWith(new Continuation<String, String>() {
   * {@literal @}Override
   * public String then(Task<String> task) {
   * try {
   * return task.getResult(IOException.class);
   * } catch (FileNotFoundException e) {
   * return "Not found";
   * } catch (IOException e) {
   * return "Read failed";
   * }
   * }
   * }
   * 
* *

To suppress all failures guard any calls to {@link Task#getResult()} with {@link * Task#isSuccessful()}: * *

   * task.continueWith(new Continuation<String, String>() {
   * {@literal @}Override
   * public String then(Task<String> task) {
   * if (task.isSuccessful()) {
   * return task.getResult();
   * } else {
   * return DEFAULT_VALUE;
   * }
   * }
   * }
   * 
* * @param task the completed Task. Never null * @throws Exception if the result couldn't be produced */ R then(@NonNull Task task) throws Exception; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy