Example usage for com.google.common.reflect Invokable toString

List of usage examples for com.google.common.reflect Invokable toString

Introduction

In this page you can find the example usage for com.google.common.reflect Invokable toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.jclouds.rest.internal.TransformerForRequest.java

@SuppressWarnings("unchecked")
@VisibleForTesting//from   w  w w . ja v a 2 s .  com
protected Key<? extends Function<HttpResponse, ?>> getParserOrThrowException(Invocation invocation) {
    Invokable<?, ?> invoked = invocation.getInvokable();
    Set<String> acceptHeaders = getAcceptHeaders.apply(invocation);
    ResponseParser annotation = invoked.getAnnotation(ResponseParser.class);
    Class<?> rawReturnType = invoked.getReturnType().getRawType();
    if (annotation == null) {
        if (rawReturnType.equals(void.class) || invoked.getReturnType().equals(futureVoidToken)) {
            return Key.get(ReleasePayloadAndReturn.class);
        } else if (rawReturnType.equals(boolean.class) || rawReturnType.equals(Boolean.class)
                || invoked.getReturnType().equals(futureBooleanToken)) {
            return Key.get(ReturnTrueIf2xx.class);
        } else if (rawReturnType.equals(InputStream.class)
                || invoked.getReturnType().equals(futureInputStreamToken)) {
            return Key.get(ReturnInputStream.class);
        } else if (rawReturnType.equals(HttpResponse.class)
                || invoked.getReturnType().equals(futureHttpResponseToken)) {
            return Key.get(Class.class.cast(IdentityFunction.class));
        } else if (acceptHeaders.contains(APPLICATION_JSON)) {
            return getJsonParserKeyForMethod(invoked);
        } else if (acceptHeaders.contains(APPLICATION_XML)
                || invoked.isAnnotationPresent(JAXBResponseParser.class)) {
            return getJAXBParserKeyForMethod(invoked);
        } else if (rawReturnType.equals(String.class) || invoked.getReturnType().equals(futureStringToken)) {
            return Key.get(ReturnStringIf2xx.class);
        } else if (rawReturnType.equals(URI.class) || invoked.getReturnType().equals(futureURIToken)) {
            return Key.get(ParseURIFromListOrLocationHeaderIf20x.class);
        } else {
            throw new IllegalStateException(
                    "You must specify a ResponseParser annotation on: " + invoked.toString());
        }
    }
    return Key.get(annotation.value());
}