List of usage examples for com.google.common.reflect Invokable getAnnotations
Annotation[] getAnnotations();
From source file:org.jclouds.http.HttpUtils.java
public static Optional<String> tryFindHttpMethod(Invokable<?, ?> method) { Builder<String> methodsBuilder = ImmutableSet.builder(); for (Annotation annotation : method.getAnnotations()) { HttpMethod http = annotation.annotationType().getAnnotation(HttpMethod.class); if (http != null) methodsBuilder.add(http.value()); }//from w ww. ja v a 2 s . com Collection<String> methods = methodsBuilder.build(); switch (methods.size()) { case 0: return Optional.absent(); case 1: return Optional.of(get(methods, 0)); default: throw new IllegalStateException("You must specify at most one HttpMethod annotation on: " + method); } }
From source file:org.jclouds.rest.internal.DelegatesToInvocationFunction.java
private Object lookupValueFromGuice(Invokable<?, ?> invoked) { try {// ww w . ja v a 2s .co m Type genericReturnType = invoked.getReturnType().getType(); try { Annotation qualifier = find(ImmutableList.copyOf(invoked.getAnnotations()), isQualifierPresent); return getInstanceOfTypeWithQualifier(genericReturnType, qualifier); } catch (ProvisionException e) { throw propagate(e.getCause()); } catch (RuntimeException e) { return instanceOfTypeOrPropagate(genericReturnType, e); } } catch (ProvisionException e) { AuthorizationException aex = getFirstThrowableOfType(e, AuthorizationException.class); if (aex != null) throw aex; throw e; } }
From source file:org.immutables.eventual.Providers.java
private EventualProvider<?> providerFor(Invokable<T, ?> method, Errors methodErrors) { Annotation[] annotations = method.getAnnotations(); verifyMethodAccessibility(methodErrors, method, source); @Nullable/*from ww w .jav a 2 s.c o m*/ Annotation bindingAnnotation = Annotations.findBindingAnnotation(methodErrors, method, annotations); verifyAbsenseOfScopeAnnotation(methodErrors, annotations, source); List<Dependency<ListenableFuture<?>>> dependencies = Lists .newArrayListWithCapacity(method.getParameters().size()); for (Parameter parameter : method.getParameters()) { dependencies.add(extractDependency(methodErrors, parameter)); } Key<ListenableFuture<?>> bindingKey; boolean exposedBinding = method.isAnnotationPresent(Exposed.class); if (isVoid(method)) { bindingKey = futureKey(TypeToken.of(Boolean.class), new BlackholedAnnotation()); exposedBinding = false; } else { bindingKey = futureKey(method.getReturnType(), bindingAnnotation); } return new EventualProvider<>(method, exposedBinding, dependencies, bindingKey, scopeAnnotation, source); }
From source file:com.google.cloud.dataflow.sdk.util.ApiSurface.java
private void addExposedTypes(Invokable<?, ?> invokable, Class<?> cause) { addExposedTypes(invokable.getReturnType(), cause); for (Annotation annotation : invokable.getAnnotations()) { logger.debug("Adding exposed types from {}, which is an annotation on invokable {}", annotation, invokable);/*from w w w. j a v a 2 s . co m*/ addExposedTypes(annotation.annotationType(), cause); } for (Parameter parameter : invokable.getParameters()) { logger.debug("Adding exposed types from {}, which is a parameter on invokable {}", parameter, invokable); addExposedTypes(parameter, cause); } for (TypeToken<?> exceptionType : invokable.getExceptionTypes()) { logger.debug("Adding exposed types from {}, which is an exception type on invokable {}", exceptionType, invokable); addExposedTypes(exceptionType, cause); } }
From source file:org.apache.beam.sdk.util.ApiSurface.java
private void addExposedTypes(Invokable<?, ?> invokable, Class<?> cause) { addExposedTypes(invokable.getReturnType(), cause); for (Annotation annotation : invokable.getAnnotations()) { LOG.debug("Adding exposed types from {}, which is an annotation on invokable {}", annotation, invokable);/*from ww w . j a va 2 s . co m*/ addExposedTypes(annotation.annotationType(), cause); } for (Parameter parameter : invokable.getParameters()) { LOG.debug("Adding exposed types from {}, which is a parameter on invokable {}", parameter, invokable); addExposedTypes(parameter, cause); } for (TypeToken<?> exceptionType : invokable.getExceptionTypes()) { LOG.debug("Adding exposed types from {}, which is an exception type on invokable {}", exceptionType, invokable); addExposedTypes(exceptionType, cause); } }