001/*
002 * Copyright (C) 2018 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005 * in compliance with the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the License
010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011 * or implied. See the License for the specific language governing permissions and limitations under
012 * the License.
013 */
014
015package com.google.common.util.concurrent.internal;
016
017/**
018 * Static utilities for {@link InternalFutureFailureAccess}. Most users will never need to use this
019 * class.
020 *
021 * <p>This class is GWT-compatible.
022 *
023 * @since {@code com.google.guava:failureaccess:1.0}, which was added as a dependency of Guava in
024 *     Guava 27.0
025 */
026public final class InternalFutures {
027  /**
028   * Usually returns {@code null} but, if the given {@code Future} has failed, may <i>optionally</i>
029   * return the cause of the failure. "Failure" means specifically "completed with an exception"; it
030   * does not include "was cancelled." To be explicit: If this method returns a non-null value,
031   * then:
032   *
033   * <ul>
034   *   <li>{@code isDone()} must return {@code true}
035   *   <li>{@code isCancelled()} must return {@code false}
036   *   <li>{@code get()} must not block, and it must throw an {@code ExecutionException} with the
037   *       return value of this method as its cause
038   * </ul>
039   */
040  public static Throwable tryInternalFastPathGetFailure(InternalFutureFailureAccess future) {
041    return future.tryInternalFastPathGetFailure();
042  }
043
044  private InternalFutures() {}
045}