Java Thread Future isSuccessful(CompletableFuture f)

Here you can find the source of isSuccessful(CompletableFuture f)

Description

Returns true if the future is done and successful.

License

Open Source License

Parameter

Parameter Description
f The future to inspect.
T The Type of the future's result.

Return

True if the given CompletableFuture has completed successfully.

Declaration

public static <T> boolean isSuccessful(CompletableFuture<T> f) 

Method Source Code

//package com.java2s;
/**/*from  w w w .  j a  va 2  s .  c  om*/
 * Copyright (c) 2017 Dell Inc., or its subsidiaries. All Rights Reserved.
 *
 * 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
 */

import java.util.concurrent.CompletableFuture;

public class Main {
    /**
     * Returns true if the future is done and successful.
     *
     * @param f   The future to inspect.
     * @param <T> The Type of the future's result.
     * @return True if the given CompletableFuture has completed successfully.
     */
    public static <T> boolean isSuccessful(CompletableFuture<T> f) {
        return f.isDone() && !f.isCompletedExceptionally() && !f.isCancelled();
    }
}

Related

  1. getResults(Iterable> futures)
  2. getSilently(Future future)
  3. getSysExeNameList()
  4. getUninterruptibly(Future future)
  5. invokeTask(String threadName, Callable callable)
  6. nanoTime()
  7. now(Collection> s)
  8. rollback(Object tx)
  9. runIfNotDoneAndGet(RunnableFuture future)