Guava Invokable - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava Invokable class.

This code example shows how to use the following methods:getReturnType, getAnnotation, isAnnotationPresent
   @VisibleForTesting 
   @SuppressWarnings({ "rawtypes", "unchecked" }) 
   public Function<HttpResponse, ?> getTransformerForMethod(Invocation invocation, Injector injector) {
      Invokable<?, ?> invoked = invocation.getInvokable();
      Function<HttpResponse, ?> transformer;
      if (invoked.isAnnotationPresent(SelectJson.class)) {
         Type returnVal = getReturnTypeFor(invoked.getReturnType());
         if (invoked.isAnnotationPresent(OnlyElement.class))
            returnVal = newParameterizedType(Set.class, returnVal);
         transformer = new ParseFirstJsonValueNamed(injector.getInstance(GsonWrapper.class),
               TypeLiteral.get(returnVal), invoked.getAnnotation(SelectJson.class).value());
         if (invoked.isAnnotationPresent(OnlyElement.class))
            transformer = compose(new OnlyElementOrNull(), transformer);
      } else { 
         transformer = injector.getInstance(getParserOrThrowException(invocation));
      } 
      return transformer;
   } 
 
   static Class<? extends HandlerWithResult<?>> getSaxResponseParserClassOrNull(Invokable<?, ?> invoked) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getParameters
      AnnotationConstructorNamingStrategy strategy = new AnnotationConstructorNamingStrategy(
            ImmutableSet.of(ConstructorProperties.class), ImmutableSet.of(new ExtractNamed()));
 
      Invokable<SimpleTest, SimpleTest> constructor = strategy.getDeserializer(typeToken(SimpleTest.class));
      assertNotNull(constructor);
      assertEquals(constructor.getParameters().size(), 4);
 
      assertEquals(strategy.translateName(constructor, 0), "aardvark");
      assertEquals(strategy.translateName(constructor, 1), "bat");
      assertEquals(strategy.translateName(constructor, 2), "coyote");
   } 
 
   public void testAnnotationConstructorFieldNamingStrategyCP() throws Exception {
      AnnotationConstructorNamingStrategy strategy = new AnnotationConstructorNamingStrategy(
            ImmutableSet.of(ConstructorProperties.class), ImmutableSet.<NameExtractor<?>>of());
 
      Invokable<SimpleTest, SimpleTest> constructor = strategy.getDeserializer(typeToken(SimpleTest.class));
      assertNotNull(constructor);
      assertEquals(constructor.getParameters().size(), 4);
 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getReturnType
      } 
      return type.getRawType();
   } 
 
   public static boolean isReturnTypeOptional(Invokable<?, ?> method) {
      return method.getReturnType().getRawType().isAssignableFrom(Optional.class);
   } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getReturnType
         return returnVal; 
      return getUnchecked(ListenableFuture.class.cast(returnVal));
   } 
 
   private boolean isFuture(Invokable<?, ?> target) {
      return target.getReturnType().getRawType().isAssignableFrom(ListenableFuture.class);
   } 
 
   @Override 
   public String toString() {
      return String.format("InvokeAndCallGetOnFutures(%s)", receiver);
   } 
 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:returning
      assertEquals(typeToken(String.class), TypeToken.of(String.class));
   } 
 
   public void testMethodFromJavaMethod() throws SecurityException, NoSuchMethodException {
      assertEquals(method(typeToken(String.class), String.class.getMethod("toString")), TypeToken.of(String.class)
            .method(String.class.getMethod("toString")).returning(String.class));
   } 
 
   public void testMethodFromClassAndNoParams() { 
      @SuppressWarnings("rawtypes") 
      Invokable<Set, Object> methodInSuper = method(Set.class, "iterator");
 
      assertEquals(methodInSuper.getOwnerType(), typeToken(Set.class));
   } 
 
   public void testMethodFromClassAndParams() { 
      @SuppressWarnings("rawtypes") 
      Invokable<Set, Object> methodInSuper = method(Set.class, "equals", Object.class);
 
      assertEquals(methodInSuper.getOwnerType(), typeToken(Set.class));
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getAnnotation
      else 
         assertEquals(assigned, expected); 
   } 
 
   protected void assertSaxResponseParserClassEquals(Invokable<?, ?> method, @Nullable Class<?> parserClass) { 
      XMLResponseParser annotation = method.getAnnotation(XMLResponseParser.class); 
      Class<?> expected =  (annotation != null) ? annotation.value() : null; 
      assertEquals(expected, parserClass); 
   } 
 
   protected void assertResponseParserClassEquals(Invokable<?, ?> method, GeneratedHttpRequest request, 
         @Nullable Class<?> parserClass) { 
      assertEquals(injector.getInstance(TransformerForRequest.class).apply(request).getClass(), parserClass); 
   } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getReturnType
      logger.trace("<< response from %s is parsed by %s", commandName, transformer.getClass().getSimpleName());
      return transformer;
   } 
 
   private boolean isFuture(Invokable<?, ?> in) {
      return in.getReturnType().getRawType().equals(ListenableFuture.class);
   } 
 
   @Override 
   public boolean equals(Object o) { 
      if (this == o)
         return true; 
      if (o == null || getClass() != o.getClass())
         return false; 
      InvokeSyncToAsyncHttpMethod that = InvokeSyncToAsyncHttpMethod.class.cast(o);
      return equal(this.annotationProcessor, that.annotationProcessor);
   } 
 
   @Override 
   public int hashCode() { 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getReturnType
      checkFilters(request);
   } 
 
   public void testNewObject() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(AtmosAsyncClient.class, "newObject");
      assertEquals(method.getReturnType().getRawType(), AtmosObject.class);
   } 
 
   @Override 
   protected void checkFilters(HttpRequest request) {
      assertEquals(request.getFilters().size(), 1);
      assertEquals(request.getFilters().get(0).getClass(), SignRequest.class);
   } 
 
   @BeforeClass 
   @Override 
   protected void setupFactory() throws IOException {
      super.setupFactory(); 
      blobToObject = injector.getInstance(BlobToObject.class);
   } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getReturnType
      checkFilters(request);
   } 
 
   public void testNewObject() throws SecurityException, NoSuchMethodException, IOException {
      Invokable<?, ?> method = method(AtmosClient.class, "newObject");
      assertEquals(method.getReturnType().getRawType(), AtmosObject.class);
   } 
 
   @Override 
   protected void checkFilters(HttpRequest request) {
      assertEquals(request.getFilters().size(), 1);
      assertEquals(request.getFilters().get(0).getClass(), SignRequest.class);
   } 
 
   @BeforeClass 
   @Override 
   protected void setupFactory() throws IOException {
      super.setupFactory(); 
      blobToObject = injector.getInstance(BlobToObject.class);
   } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Guava Invokable Methods: