Package jadex.commons.future
Class Tuple2Future<E,F>
- java.lang.Object
- 
- jadex.commons.future.Future<java.util.Collection<E>>
- 
- jadex.commons.future.IntermediateFuture<TupleResult>
- 
- jadex.commons.future.Tuple2Future<E,F>
 
 
 
- 
- All Implemented Interfaces:
- IForwardCommandFuture,- IFuture<java.util.Collection<TupleResult>>,- IIntermediateFuture<TupleResult>,- ITuple2Future<E,F>
 
 public class Tuple2Future<E,F> extends IntermediateFuture<TupleResult> implements ITuple2Future<E,F> Implementation of tuple2 future. The future is considered as finished when all tuple elements have been set.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface jadex.commons.future.IForwardCommandFutureIForwardCommandFuture.Type
 
- 
 - 
Field Summary- 
Fields inherited from class jadex.commons.future.IntermediateFutureicallers, indices, intermediate, notcommand, results
 - 
Fields inherited from class jadex.commons.future.FutureCALLER_QUEUED, CALLER_RESUMED, CALLER_SUSPENDED, callers, creation, DEBUG, exception, first, listener, listeners, NO_STACK_COMPACTION, NONE, notifications, result, resultavailable, STACK, undone, UNSET
 - 
Fields inherited from interface jadex.commons.future.IIntermediateFutureDONE
 
- 
 - 
Constructor SummaryConstructors Constructor Description Tuple2Future()Create a future that is already done.Tuple2Future(E result1, F result2)Create a future that is already done.Tuple2Future(java.lang.Exception exception)Create a future that is already done (failed).
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddTuple2ResultListener(IFunctionalResultListener<E> firstListener, IFunctionalResultListener<F> secondListener)Uses two functional result listeners to create a Tuple2ResultListener and add it.voidaddTuple2ResultListener(IFunctionalResultListener<E> firstListener, IFunctionalResultListener<F> secondListener, IFunctionalExceptionListener exceptionListener)Uses two functional result listeners to create a Tuple2ResultListener and add it.protected TupleResultfindResult(int idx)Find result in resultsEgetFirstResult()Get the first result.EgetFirstResult(long timeout)Get the first result.EgetFirstResult(long timeout, boolean realtime)Get the first result.EgetFirstResult(ThreadSuspendable sus)Deprecated.- From 3.0.protected intgetMax()Get the number of results of the type of future..FgetSecondResult()Get the second result.FgetSecondResult(long timeout)Get the second result.FgetSecondResult(long timeout, boolean realtime)Get the second result.protected java.lang.ObjectgetXResult(int idx, long timeout, boolean realtime)Get the x result.protected voidnotifyIntermediateResult(IIntermediateResultListener<TupleResult> listener, TupleResult result)Notify a result listener.voidsetFirstResult(E result)Set the result.voidsetFirstResultIfUndone(E result)Set the result.voidsetSecondResult(F result)Set the result.voidsetSecondResultIfUndone(F result)Set the result.protected voidsetXResult(int idx, java.lang.Object res)Set the xth result.protected voidsetXResultIfUndone(int idx, java.lang.Object res)Set the xth result.- 
Methods inherited from class jadex.commons.future.IntermediateFutureaddIntermediateResult, addIntermediateResultIfUndone, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addResultListener, doAddIntermediateResult, doGetNextIntermediateResult, doSetFinished, doSetResult, flatMapAsync, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, getNextIntermediateResult, getNotificationCommand, hasNextIntermediateResult, hasNextIntermediateResult, mapAsync, mapAsync, resume, resumeIntermediate, setFinished, setFinishedIfUndone, storeResult
 - 
Methods inherited from class jadex.commons.future.FutureabortGet, acceptEither, addResultListener, addResultListener, applyToEither, delegate, doSetException, exceptionally, exceptionally, exceptionally, executeNotification, get, get, get, get, get, getEmptyFuture, getException, getFuture, hasResultListener, isDone, notifyListener, notifyListener, scheduleNotification, scheduleNotification, scheduleNotification, sendForwardCommand, setException, setExceptionIfUndone, setResult, setResultIfUndone, startScheduledNotifications, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jadex.commons.future.IFutureacceptEither, addResultListener, addResultListener, addResultListener, applyToEither, delegate, exceptionally, exceptionally, exceptionally, get, get, get, get, get, getException, isDone, thenAccept, thenAccept, thenApply, thenApply, thenCombine, thenCompose, thenCompose
 - 
Methods inherited from interface jadex.commons.future.IIntermediateFutureaddIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, addIntermediateResultListener, flatMapAsync, getIntermediateResults, getNextIntermediateResult, getNextIntermediateResult, hasNextIntermediateResult, hasNextIntermediateResult, mapAsync, mapAsync
 
- 
 
- 
- 
- 
Constructor Detail- 
Tuple2Futurepublic Tuple2Future() Create a future that is already done.- Parameters:
- result- The result, if any.
 
 - 
Tuple2Futurepublic Tuple2Future(E result1, F result2) Create a future that is already done.- Parameters:
- result- The result, if any.
 
 - 
Tuple2Futurepublic Tuple2Future(java.lang.Exception exception) Create a future that is already done (failed).- Parameters:
- exception- The exception.
 
 
- 
 - 
Method Detail- 
getFirstResultpublic E getFirstResult(ThreadSuspendable sus) Deprecated.- From 3.0. Use method without suspendable. Will NOT use the suspendable that is supplied as parameter. Get the first result.- Specified by:
- getFirstResultin interface- ITuple2Future<E,F>
- Returns:
- The next intermediate result.
 
 - 
getFirstResultpublic E getFirstResult() Get the first result.- Specified by:
- getFirstResultin interface- ITuple2Future<E,F>
- Returns:
- The next intermediate result.
 
 - 
getSecondResultpublic F getSecondResult() Get the second result.- Specified by:
- getSecondResultin interface- ITuple2Future<E,F>
- Returns:
- The next intermediate result.
 
 - 
getFirstResultpublic E getFirstResult(long timeout) Get the first result.- Specified by:
- getFirstResultin interface- ITuple2Future<E,F>
- Parameters:
- timeout- The timeout in millis.
- Returns:
- The next intermediate result.
 
 - 
getSecondResultpublic F getSecondResult(long timeout) Get the second result.- Specified by:
- getSecondResultin interface- ITuple2Future<E,F>
- Parameters:
- timeout- The timeout in millis.
- Returns:
- The next intermediate result.
 
 - 
getFirstResultpublic E getFirstResult(long timeout, boolean realtime) Get the first result.- Specified by:
- getFirstResultin interface- ITuple2Future<E,F>
- Parameters:
- timeout- The timeout in millis.
- realtime- Flag if wait should be realtime (in contrast to simulation time).
- Returns:
- The next intermediate result.
 
 - 
getSecondResultpublic F getSecondResult(long timeout, boolean realtime) Get the second result.- Specified by:
- getSecondResultin interface- ITuple2Future<E,F>
- Parameters:
- timeout- The timeout in millis.
- realtime- Flag if wait should be realtime (in contrast to simulation time).
- Returns:
- The next intermediate result.
 
 - 
setFirstResultpublic void setFirstResult(E result) Set the result. Listener notifications occur on calling thread of this method.- Parameters:
- result- The result.
 
 - 
setSecondResultpublic void setSecondResult(F result) Set the result. Listener notifications occur on calling thread of this method.- Parameters:
- result- The result.
 
 - 
setFirstResultIfUndonepublic void setFirstResultIfUndone(E result) Set the result. Listener notifications occur on calling thread of this method.- Parameters:
- result- The result.
 
 - 
addTuple2ResultListenerpublic void addTuple2ResultListener(IFunctionalResultListener<E> firstListener, IFunctionalResultListener<F> secondListener) Uses two functional result listeners to create a Tuple2ResultListener and add it. The first listener is called upon reception of the first result, the second is called for the second result. Exceptions will be logged to console.- Specified by:
- addTuple2ResultListenerin interface- ITuple2Future<E,F>
- Parameters:
- firstListener- Listener for the first available result.
- secondListener- Listener for the second available result.
 
 - 
addTuple2ResultListenerpublic void addTuple2ResultListener(IFunctionalResultListener<E> firstListener, IFunctionalResultListener<F> secondListener, IFunctionalExceptionListener exceptionListener) Uses two functional result listeners to create a Tuple2ResultListener and add it. The first listener is called upon reception of the first result, the second is called for the second result. Additionally, a given exception listener is called when exceptions occur.- Specified by:
- addTuple2ResultListenerin interface- ITuple2Future<E,F>
- Parameters:
- firstListener- Listener for the first available result.
- secondListener- Listener for the second available result.
- exListener- The listener that is called on exceptions. Passing- nullenables default exception logging.
 
 - 
setSecondResultIfUndonepublic void setSecondResultIfUndone(F result) Set the result. Listener notifications occur on calling thread of this method.- Parameters:
- result- The result.
 
 - 
setXResultprotected void setXResult(int idx, java.lang.Object res)Set the xth result.
 - 
setXResultIfUndoneprotected void setXResultIfUndone(int idx, java.lang.Object res)Set the xth result.
 - 
getXResultprotected java.lang.Object getXResult(int idx, long timeout, boolean realtime)Get the x result.- Returns:
- The next intermediate result.
 
 - 
findResultprotected TupleResult findResult(int idx) Find result in results
 - 
getMaxprotected int getMax() Get the number of results of the type of future..
 - 
notifyIntermediateResultprotected void notifyIntermediateResult(IIntermediateResultListener<TupleResult> listener, TupleResult result) Notify a result listener.- Overrides:
- notifyIntermediateResultin class- IntermediateFuture<TupleResult>
- Parameters:
- listener- The listener.
 
 
- 
 
-