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

org.infinispan.commons.util.concurrent.NoOpFuture Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.commons.util.concurrent;

import java.util.concurrent.*;
import java.util.concurrent.TimeoutException;

/**
 * A future that doesn't do anything and simply returns a given return value.
 *
 * @author Manik Surtani
 * @since 5.1
 */
public class NoOpFuture implements NotifyingNotifiableFuture {
   private final E returnValue;

   public NoOpFuture(E returnValue) {
      this.returnValue = returnValue;
   }

   @Override
   public boolean cancel(boolean b) {
      return false;
   }

   @Override
   public boolean isCancelled() {
      return false;
   }

   @Override
   public boolean isDone() {
      return true;
   }

   @Override
   public E get() throws InterruptedException, ExecutionException {
      return returnValue;
   }

   @Override
   public E get(long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
      return returnValue;
   }

   @Override
   public void notifyDone(E result) {
      throw new UnsupportedOperationException();
   }

   @Override
   public void notifyException(Throwable exception) {
      throw new UnsupportedOperationException();
   }

   @Override
   public void setFuture(Future eFuture) {
      throw new UnsupportedOperationException();
   }

   @Override
   public NotifyingFuture attachListener(FutureListener eFutureListener) {
      eFutureListener.futureDone(this);
      return this;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy