One last tweak to TypeConverter.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@368 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/src/com/google/inject/BinderImpl.java b/src/com/google/inject/BinderImpl.java
index 6ffa424..727b9b7 100644
--- a/src/com/google/inject/BinderImpl.java
+++ b/src/com/google/inject/BinderImpl.java
@@ -111,7 +111,7 @@
convertToPrimitiveType(double.class, Double.class);
TypeConverter characterConverter = new TypeConverter() {
- public Object convert(TypeLiteral<?> requiredType, String value) {
+ public Object convert(String value, TypeLiteral<?> toType) {
value = value.trim();
if (value.length() != 1) {
throw new RuntimeException("Length != 1.");
@@ -130,8 +130,8 @@
convertToClasses(Matchers.subclassesOf(Enum.class), new TypeConverter() {
@SuppressWarnings("unchecked")
- public Object convert(TypeLiteral<?> requiredType, String value) {
- return Enum.valueOf((Class) requiredType.getRawType(), value);
+ public Object convert(String value, TypeLiteral<?> toType) {
+ return Enum.valueOf((Class) toType.getRawType(), value);
}
@Override
@@ -153,7 +153,7 @@
},
new TypeConverter() {
@SuppressWarnings("unchecked")
- public Object convert(TypeLiteral<?> requiredType, String value) {
+ public Object convert(String value, TypeLiteral<?> toType) {
try {
return Class.forName(value);
}
@@ -222,7 +222,7 @@
TypeConverter typeConverter = new TypeConverter() {
@SuppressWarnings("unchecked")
- public Object convert(TypeLiteral<?> requiredType, String value) {
+ public Object convert(String value, TypeLiteral<?> toType) {
try {
return (T) parser.invoke(null, value);
}
diff --git a/src/com/google/inject/InjectorImpl.java b/src/com/google/inject/InjectorImpl.java
index 7d62c68..52cc5f9 100644
--- a/src/com/google/inject/InjectorImpl.java
+++ b/src/com/google/inject/InjectorImpl.java
@@ -19,7 +19,6 @@
import com.google.inject.internal.GuiceFastClass;
import com.google.inject.internal.ReferenceCache;
import com.google.inject.internal.StackTraceElements;
-import com.google.inject.internal.Strings;
import com.google.inject.internal.ToStringBuilder;
import com.google.inject.internal.Classes;
import com.google.inject.spi.SourceProviders;
@@ -343,8 +342,7 @@
try {
// This cast is safe because we double check below.
@SuppressWarnings("unchecked")
- T converted = (T) matchingConverter.typeConverter.convert(
- key.getTypeLiteral(), stringValue);
+ T converted = (T) matchingConverter.typeConverter.convert(stringValue, key.getTypeLiteral());
if (converted == null) {
throw new RuntimeException("Converter returned null.");
diff --git a/src/com/google/inject/spi/TypeConverter.java b/src/com/google/inject/spi/TypeConverter.java
index a8d8e6f..d9d826a 100644
--- a/src/com/google/inject/spi/TypeConverter.java
+++ b/src/com/google/inject/spi/TypeConverter.java
@@ -16,7 +16,6 @@
package com.google.inject.spi;
-import com.google.inject.Key;
import com.google.inject.TypeLiteral;
/**
@@ -29,5 +28,5 @@
/**
* Converts a string value. Throws an exception if a conversion error occurs.
*/
- Object convert(TypeLiteral<?> requiredType, String value);
+ Object convert(String value, TypeLiteral<?> toType);
}