@Test public void ordered() { final List<String> order = new ArrayList<String>(); channel = new Channel() { @SuppressWarnings("unchecked") @Override public <ReqT, RespT> ClientCall<ReqT, RespT> newCall( MethodDescriptor<ReqT, RespT> method, CallOptions callOptions) { order.add("channel"); return (ClientCall<ReqT, RespT>) call; } @Override public String authority() { return null; } }; ClientInterceptor interceptor1 = new ClientInterceptor() { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) { order.add("i1"); return next.newCall(method, callOptions); } }; ClientInterceptor interceptor2 = new ClientInterceptor() { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) { order.add("i2"); return next.newCall(method, callOptions); } }; Channel intercepted = ClientInterceptors.intercept(channel, interceptor1, interceptor2); assertSame(call, intercepted.newCall(method, CallOptions.DEFAULT)); assertEquals(Arrays.asList("i2", "i1", "channel"), order); }
public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); static Channel interceptForward(Channel channel, ClientInterceptor... interceptors); static Channel interceptForward(Channel channel,
                                         List<? extends ClientInterceptor> interceptors); static Channel intercept(Channel channel, ClientInterceptor... interceptors); static Channel intercept(Channel channel, List<? extends ClientInterceptor> interceptors); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); static Channel interceptForward(Channel channel, ClientInterceptor... interceptors); static Channel interceptForward(Channel channel,
                                         List<? extends ClientInterceptor> interceptors); static Channel intercept(Channel channel, ClientInterceptor... interceptors); static Channel intercept(Channel channel, List<? extends ClientInterceptor> interceptors);  }