Class WaitForAsyncUtils.ASyncFXCallable<X>

  • Type Parameters:
    X - the return type of the callable
    All Implemented Interfaces:
    java.lang.Runnable, java.util.concurrent.Callable<X>, java.util.concurrent.Future<X>, java.util.concurrent.RunnableFuture<X>
    Enclosing class:
    WaitForAsyncUtils

    private static class WaitForAsyncUtils.ASyncFXCallable<X>
    extends java.util.concurrent.FutureTask<X>
    implements java.util.concurrent.Callable<X>
    Internally used Callable that handles all the async stuff. All external Callables/Runnables must be wrapped in this class.

    Note: This is a single call object. Do not use twice!

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Throwable exception
      The unhandled exception.
      private boolean throwException
      If true, exceptions will be added to the internal stack.
      private java.lang.StackTraceElement[] trace
      Holds the stacktrace of the caller, for printing, if an Exception occurs.
    • Constructor Summary

      Constructors 
      Constructor Description
      ASyncFXCallable​(java.lang.Runnable runnable, boolean throwException)  
      ASyncFXCallable​(java.util.concurrent.Callable<X> callable, boolean throwException)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      X call()  
      X get()  
      X get​(long timeout, java.util.concurrent.TimeUnit unit)  
      protected void setException​(java.lang.Throwable throwable)
      Called to handle exceptions during run().
      private java.lang.Throwable transformException​(java.lang.Throwable exception)
      Transforms am exception to be a throwable.
      • Methods inherited from class java.util.concurrent.FutureTask

        cancel, done, isCancelled, isDone, run, runAndReset, set, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • throwException

        private final boolean throwException
        If true, exceptions will be added to the internal stack.
      • trace

        private final java.lang.StackTraceElement[] trace
        Holds the stacktrace of the caller, for printing, if an Exception occurs.
      • exception

        private java.lang.Throwable exception
        The unhandled exception.
    • Constructor Detail

      • ASyncFXCallable

        public ASyncFXCallable​(java.lang.Runnable runnable,
                               boolean throwException)
      • ASyncFXCallable

        public ASyncFXCallable​(java.util.concurrent.Callable<X> callable,
                               boolean throwException)
    • Method Detail

      • setException

        protected void setException​(java.lang.Throwable throwable)
        Called to handle exceptions during run().
        Overrides:
        setException in class java.util.concurrent.FutureTask<X>
      • transformException

        private java.lang.Throwable transformException​(java.lang.Throwable exception)
        Transforms am exception to be a throwable. Basically wraps the exception in a RuntimeException, if it is not already one.
        Parameters:
        exception - the exception to transform
        Returns:
        the throwable exception
      • call

        public X call()
               throws java.lang.Exception
        Specified by:
        call in interface java.util.concurrent.Callable<X>
        Throws:
        java.lang.Exception
      • get

        public X get()
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException
        Specified by:
        get in interface java.util.concurrent.Future<X>
        Overrides:
        get in class java.util.concurrent.FutureTask<X>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • get

        public X get​(long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException,
                     java.util.concurrent.TimeoutException
        Specified by:
        get in interface java.util.concurrent.Future<X>
        Overrides:
        get in class java.util.concurrent.FutureTask<X>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException