Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * COMSAT
   * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved.
   *
   * This program and the accompanying materials are dual-licensed under
   * either the terms of the Eclipse Public License v1.0 as published by
   * the Eclipse Foundation
   *
   *   or (per the licensee's choosing)
  *
  * under the terms of the GNU Lesser General Public License version 3.0
  * as published by the Free Software Foundation.
  */
 package co.paralleluniverse.fibers.ws.rs.client;
 
 import  co.paralleluniverse.fibers.SuspendExecution;
 import  co.paralleluniverse.fibers.Suspendable;
 import  co.paralleluniverse.strands.SettableFuture;
 
 class FiberInvocation implements Invocation {
     private final Invocation invocation;
 
     public FiberInvocation(Invocation invocation) {
         this. = invocation;
     }
 
     @Override
     public FiberInvocation property(String nameObject value) {
         .property(namevalue);
         return this;
     }
 
     @Override
     @Suspendable
     public Response invoke() {
         try {
             return new AsyncRs<Response>() {
                 @Override
                 protected void requestAsync() {
                     .submit(this);
                 }
             }.run();
         } catch (SuspendExecution ex) {
             throw new AssertionError(ex);
         }
     }
 
     @Override
     @Suspendable
     public <T> T invoke(Class<T> responseType) {
         try {
             return new AsyncRs<T>() {
                 @Override
                 protected void requestAsync() {
                     .submit(this);
                 }
             }.run();
         } catch (SuspendExecution ex) {
             throw new AssertionError(ex);
         }
     }
 
     @Override
     @Suspendable
     public <T> T invoke(GenericType<T> responseType) {
         try {
             return new AsyncRs<T>() {
                 @Override
                 protected void requestAsync() {
                     .submit(this);
                 }
             }.run();
         } catch (SuspendExecution ex) {
             throw new AssertionError(ex);
         }
     }
 
     @Override
     public Future<Responsesubmit() {
         final SettableFuture<ResponseresponseFuture = new SettableFuture<>();
         .submit(new InvocationCallback<Response>() {
 
             @Override
             public void completed(Response response) {
                 responseFuture.set(response);
             }
 
             @Override
             public void failed(Throwable throwable) {
                 responseFuture.setException(throwable);
             }
         });                
         return responseFuture;
     }
    @Override
    public <T> Future<T> submit(Class<T> responseType) {
        final SettableFuture<T> responseFuture = new SettableFuture<>();
        .submit(new InvocationCallback<T>() {
            @Override
            public void completed(T response) {
                responseFuture.set(response);
            }
            @Override
            public void failed(Throwable throwable) {
                responseFuture.setException(throwable);
            }
        });                
        return responseFuture;
    }
    @Override
    public <T> Future<T> submit(GenericType<T> responseType) {
        final SettableFuture<T> responseFuture = new SettableFuture<>();
        .submit(new InvocationCallback<T>() {
            @Override
            public void completed(T response) {
                responseFuture.set(response);
            }
            @Override
            public void failed(Throwable throwable) {
                responseFuture.setException(throwable);
            }
        });                
        return responseFuture;
    }
    @Override
    public <T> Future<T> submit(final InvocationCallback<T> callback) {
        final SettableFuture<T> responseFuture = new SettableFuture<>();
        .submit(new InvocationCallback<T>() {
            @Override
            public void completed(T response) {
                responseFuture.set(response);
                callback.completed(response);
            }
            @Override
            public void failed(Throwable throwable) {
                responseFuture.setException(throwable);
                callback.failed(throwable);
            }
        });                
        return responseFuture;
    }
    @Override
    public int hashCode() {
        return .hashCode();
    }
    @Override
    public boolean equals(Object obj) {
        return .equals(obj);
    }
    @Override
    public String toString() {
        return .toString();
    }
    
New to GrepCode? Check out our FAQ X