SHARE
TWEET

Untitled

a guest Sep 19th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class TailCallUtility {
  2.  
  3.     private TailCallUtility() {
  4.     }
  5.  
  6.     public static <T> TailCall<T> done(T result) {
  7.  
  8.         return new TailCallResult<T>(result);
  9.     }
  10.  
  11.     public static <T> TailCall<T> call(TailCall<T> nextCall) {
  12.         return nextCall;
  13.     }
  14.  
  15.     private static class TailCallResult<T> implements TailCall<T> {
  16.  
  17.         private final T result;
  18.  
  19.         TailCallResult(T result) {
  20.             this.result = result;
  21.         }
  22.  
  23.         @Override
  24.         public TailCall<T> apply() {
  25.             throw new UnsupportedOperationException();
  26.         }
  27.  
  28.         @Override
  29.         public Boolean isComplete() {
  30.             return Boolean.TRUE;
  31.         }
  32.  
  33.         @Override
  34.         public T result() {
  35.             return this.result;
  36.         }
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top