You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/01/17 19:25:27 UTC

git commit: Checking if Guava is broken

Updated Branches:
  refs/heads/JCLOUDS-427 cdb6eb927 -> 5f919cb9e


Checking if Guava is broken


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/5f919cb9
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/5f919cb9
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/5f919cb9

Branch: refs/heads/JCLOUDS-427
Commit: 5f919cb9edc09690bdf94a6179d864149abb8e19
Parents: cdb6eb9
Author: Andrew Phillips <an...@apache.org>
Authored: Fri Jan 17 13:25:11 2014 -0500
Committer: Andrew Phillips <an...@apache.org>
Committed: Fri Jan 17 13:25:11 2014 -0500

----------------------------------------------------------------------
 .../main/java/org/jclouds/rest/config/BinderUtils.java | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/5f919cb9/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
index da417cf..11c5f25 100644
--- a/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
+++ b/core/src/main/java/org/jclouds/rest/config/BinderUtils.java
@@ -20,6 +20,7 @@ import com.google.common.reflect.TypeParameter;
 import com.google.common.reflect.TypeToken;
 import com.google.inject.Binder;
 import com.google.inject.TypeLiteral;
+import java.util.Map;
 
 /**
  * 
@@ -101,11 +102,12 @@ public class BinderUtils {
    private static <S, A> void bindHttpApiProvider(Binder binder, Class<S> sync, Class<A> async) {
       TypeToken<SyncToAsyncHttpApiProvider<S, A>> token = new TypeToken<SyncToAsyncHttpApiProvider<S, A>>() {
       };
+      System.out.println("Printing Guava sample for 'where': " + mapOf(TypeToken.of(String.class), TypeToken.of(Integer.class)));
       System.out.println("**** token now (step 1): " + token);
       token = token.where(new TypeParameter<A>() {}, async);
       System.out.println("**** token now (after A): " + token);
-      token = token.where(new TypeParameter<S>() {}, sync);
-      System.out.println("**** token now (after S): " + token);
+      token = token.where(new TypeParameter<S>() {}, TypeToken.of(sync));
+      System.out.println("**** token now (after S, using TypeToken): " + token);
       try {
       binder.bind(sync).toProvider(TypeLiteral.class.cast(TypeLiteral.get(token.getType())));
       } catch(RuntimeException e) {
@@ -114,6 +116,13 @@ public class BinderUtils {
       }
    }
    
+   public static <K, V> TypeToken<Map<K, V>> mapOf(
+       TypeToken<K> keyType, TypeToken<V> valueType) {
+     return new TypeToken<Map<K, V>>() {}
+         .where(new TypeParameter<K>() {}, keyType)
+         .where(new TypeParameter<V>() {}, valueType);
+   }
+   
    /**
     * adds an explicit binding for an interface which synchronously blocks on
     * similar calls to an {@code async} type.