From 39684339724ce966332deb846061d12701db99f2 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 6 May 2014 20:39:47 -0400 Subject: core: Make TypeLiterals use JSR-330 Providers. --- .../src/main/java/com/tavianator/sangria/core/TypeLiterals.java | 9 ++++++--- .../test/java/com/tavianator/sangria/core/TypeLiteralsTest.java | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'sangria-core') diff --git a/sangria-core/src/main/java/com/tavianator/sangria/core/TypeLiterals.java b/sangria-core/src/main/java/com/tavianator/sangria/core/TypeLiterals.java index 833f70d..ff42790 100644 --- a/sangria-core/src/main/java/com/tavianator/sangria/core/TypeLiterals.java +++ b/sangria-core/src/main/java/com/tavianator/sangria/core/TypeLiterals.java @@ -19,7 +19,8 @@ package com.tavianator.sangria.core; import java.util.*; -import com.google.inject.Provider; +import javax.inject.Provider; + import com.google.inject.TypeLiteral; import com.google.inject.util.Types; @@ -77,11 +78,13 @@ public class TypeLiterals { @SuppressWarnings("unchecked") public static TypeLiteral> providerOf(Class type) { - return (TypeLiteral>)TypeLiteral.get(Types.providerOf(type)); + // Can't use Types.providerOf() because we want to stick to JSR-330 Providers + return (TypeLiteral>)TypeLiteral.get(Types.newParameterizedType(Provider.class, type)); } @SuppressWarnings("unchecked") public static TypeLiteral> providerOf(TypeLiteral type) { - return (TypeLiteral>)TypeLiteral.get(Types.providerOf(type.getType())); + // Can't use Types.providerOf() because we want to stick to JSR-330 Providers + return (TypeLiteral>)TypeLiteral.get(Types.newParameterizedType(Provider.class, type.getType())); } } diff --git a/sangria-core/src/test/java/com/tavianator/sangria/core/TypeLiteralsTest.java b/sangria-core/src/test/java/com/tavianator/sangria/core/TypeLiteralsTest.java index 93dea77..3e7cdb8 100644 --- a/sangria-core/src/test/java/com/tavianator/sangria/core/TypeLiteralsTest.java +++ b/sangria-core/src/test/java/com/tavianator/sangria/core/TypeLiteralsTest.java @@ -19,7 +19,8 @@ package com.tavianator.sangria.core; import java.util.*; -import com.google.inject.Provider; +import javax.inject.Provider; + import com.google.inject.TypeLiteral; import org.hamcrest.Matcher; import org.hamcrest.Matchers; -- cgit v1.2.3