From a7389ac9eba677da5a17c22b174c18741b2612a7 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 12 Jan 2013 07:49:01 -0800 Subject: [PATCH] equals on different types --- .../rest/internal/TransformerForRequest.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java b/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java index af7de21ca7..a9d2541508 100644 --- a/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java +++ b/core/src/main/java/org/jclouds/rest/internal/TransformerForRequest.java @@ -111,22 +111,22 @@ public class TransformerForRequest implements Function> futureBooleanLiteral = new TypeToken>() { + private static final TypeToken> futureBooleanToken = new TypeToken>() { private static final long serialVersionUID = 1L; }; - private static final TypeToken> futureStringLiteral = new TypeToken>() { + private static final TypeToken> futureStringToken = new TypeToken>() { private static final long serialVersionUID = 1L; }; - private static final TypeToken> futureVoidLiteral = new TypeToken>() { + private static final TypeToken> futureVoidToken = new TypeToken>() { private static final long serialVersionUID = 1L; }; - private static final TypeToken> futureURILiteral = new TypeToken>() { + private static final TypeToken> futureURIToken = new TypeToken>() { private static final long serialVersionUID = 1L; }; - private static final TypeToken> futureInputStreamLiteral = new TypeToken>() { + private static final TypeToken> futureInputStreamToken = new TypeToken>() { private static final long serialVersionUID = 1L; }; - private static final TypeToken> futureHttpResponseLiteral = new TypeToken>() { + private static final TypeToken> futureHttpResponseToken = new TypeToken>() { private static final long serialVersionUID = 1L; }; @@ -136,25 +136,26 @@ public class TransformerForRequest implements Function invoked = invocation.getInvokable(); Set acceptHeaders = getAcceptHeaders.apply(invocation); ResponseParser annotation = invoked.getAnnotation(ResponseParser.class); + Class rawReturnType = invoked.getReturnType().getRawType(); if (annotation == null) { - if (invoked.getReturnType().equals(void.class) || invoked.getReturnType().equals(futureVoidLiteral)) { + if (rawReturnType.equals(void.class) || invoked.getReturnType().equals(futureVoidToken)) { return Key.get(ReleasePayloadAndReturn.class); - } else if (invoked.getReturnType().equals(boolean.class) || invoked.getReturnType().equals(Boolean.class) - || invoked.getReturnType().equals(futureBooleanLiteral)) { + } else if (rawReturnType.equals(boolean.class) || rawReturnType.equals(Boolean.class) + || invoked.getReturnType().equals(futureBooleanToken)) { return Key.get(ReturnTrueIf2xx.class); - } else if (invoked.getReturnType().equals(InputStream.class) - || invoked.getReturnType().equals(futureInputStreamLiteral)) { + } else if (rawReturnType.equals(InputStream.class) + || invoked.getReturnType().equals(futureInputStreamToken)) { return Key.get(ReturnInputStream.class); - } else if (invoked.getReturnType().equals(HttpResponse.class) - || invoked.getReturnType().equals(futureHttpResponseLiteral)) { + } 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 (invoked.getReturnType().equals(String.class) || invoked.getReturnType().equals(futureStringLiteral)) { + } else if (rawReturnType.equals(String.class) || invoked.getReturnType().equals(futureStringToken)) { return Key.get(ReturnStringIf2xx.class); - } else if (invoked.getReturnType().equals(URI.class) || invoked.getReturnType().equals(futureURILiteral)) { + } 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());