diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionService.java b/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionService.java
index a7966e8932..409bc8f198 100644
--- a/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionService.java
+++ b/org.springframework.core/src/main/java/org/springframework/core/convert/ConversionService.java
@@ -21,8 +21,6 @@ package org.springframework.core.convert;
* this system. Call one of the getConversionExecutor operations to obtain
* a thread-safe {@link ConversionExecutor} command for later use.
*
- * TODO - is TypeDescriptor/TypedValue needed on source?
- *
* @author Keith Donald
*/
public interface ConversionService {
@@ -33,10 +31,10 @@ public interface ConversionService {
* @param targetType the target type to convert to
* @return true if a conversion can be performed, false if not
*/
- public boolean canConvert(TypedValue source, TypeDescriptor targetType);
+ public boolean canConvert(Object source, TypeDescriptor targetType);
/**
- * Convert the source to target type T.
+ * Convert the source to targetType.
* @param source the source to convert from (may be null)
* @param targetType the target type to convert to
* @return the converted object, an instance of the targetType, or null if a null source
@@ -45,11 +43,11 @@ public interface ConversionService {
* source to an instance of targetType
* @throws ConversionException if an exception occurred during the conversion process
*/
- public Object executeConversion(TypedValue source, TypeDescriptor targetType) throws ConversionExecutorNotFoundException,
+ public Object executeConversion(Object source, TypeDescriptor targetType) throws ConversionExecutorNotFoundException,
ConversionException;
/**
- * Convert the source to target type T with a custom converter.
+ * Convert the source to targetType using a custom converter.
* @param converterId the id of the custom converter, which must be registered with this conversion service and
* capable of converting to the targetType
* @param source the source to convert from (may be null)
@@ -60,22 +58,22 @@ public interface ConversionService {
* source to an instance of targetType
* @throws ConversionException if an exception occurred during the conversion process
*/
- public Object executeConversion(String converterId, TypedValue source, TypeDescriptor targetType)
+ public Object executeConversion(String converterId, Object source, TypeDescriptor targetType)
throws ConversionExecutorNotFoundException, ConversionException;
/**
- * Get a ConversionExecutor that converts objects from S to T.
+ * Get a ConversionExecutor that converts objects from sourceType to targetType.
* The returned ConversionExecutor is thread-safe and may safely be cached for later use by client code.
* @param sourceType the source type to convert from (required)
* @param targetType the target type to convert to (required)
* @return the executor that can execute instance type conversion, never null
* @throws ConversionExecutorNotFoundException when no suitable conversion executor could be found
*/
- public ConversionExecutor getConversionExecutor(TypeDescriptor sourceType, TypeDescriptor targetType)
+ public ConversionExecutor getConversionExecutor(Class> sourceType, TypeDescriptor targetType)
throws ConversionExecutorNotFoundException;
/**
- * Get a ConversionExecutor that that converts objects from S to T with a custom converter.
+ * Get a ConversionExecutor that converts objects from from sourceType to targetType using a custom converter.
* The returned ConversionExecutor is thread-safe and may safely be cached for use in client code.
* @param converterId the id of the custom converter, which must be registered with this conversion service and
* capable of converting from sourceType to targetType (required)
@@ -84,7 +82,7 @@ public interface ConversionService {
* @return the executor that can execute instance type conversion, never null
* @throws ConversionExecutorNotFoundException when no suitable conversion executor could be found
*/
- public ConversionExecutor getConversionExecutor(String converterId, TypeDescriptor sourceType,
+ public ConversionExecutor getConversionExecutor(String converterId, Class> sourceType,
TypeDescriptor targetType) throws ConversionExecutorNotFoundException;
/**
diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/TypedValue.java b/org.springframework.core/src/main/java/org/springframework/core/convert/TypedValue.java
deleted file mode 100644
index 16e222ffe8..0000000000
--- a/org.springframework.core/src/main/java/org/springframework/core/convert/TypedValue.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2004-2009 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.springframework.core.convert;
-
-/**
- * A value with additional context about its type.
- * The additional context provides information about how the value was obtained; for example from a field read or getter return value.
- * This additional context allows access to generic information associated with a field, return value, or method argument.
- * It also allows access to field-level or method-level annotations.
- * All of this context can be utilized when performing a type conversion as part of a data binding routine.
- *
- * TODO - is this needed?
- *
- * @author Keith Donald
- */
-public class TypedValue {
-
- /**
- * The NULL TypedValue object.
- */
- public static final TypedValue NULL = new TypedValue(null);
-
- private final Object value;
-
- private final TypeDescriptor typeDescriptor;
-
- /**
- * Creates a new typed value.
- * @param value the actual value (may be null)
- */
- public TypedValue(Object value) {
- this.value = value;
- if (this.value != null) {
- typeDescriptor = TypeDescriptor.valueOf(value.getClass());
- } else {
- typeDescriptor = null;
- }
- }
-
- /**
- * Creates a new typed value.
- * @param value the actual value (may be null)
- * @param typeDescriptor the value type descriptor (may be null)
- */
- public TypedValue(Object value, TypeDescriptor typeDescriptor) {
- this.value = value;
- this.typeDescriptor = typeDescriptor;
- }
-
- /**
- * The actual value. May be null.
- */
- public Object getValue() {
- return value;
- }
-
- /**
- * Provides additional type context about the value. May be null.
- */
- public TypeDescriptor getTypeDescriptor() {
- return typeDescriptor;
- }
-
- /**
- * True if both the actual value and type descriptor are null.
- */
- public boolean isNull() {
- return value == null && typeDescriptor == null;
- }
-
-}
diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/service/GenericConversionService.java b/org.springframework.core/src/main/java/org/springframework/core/convert/service/GenericConversionService.java
index 1ac6d14b6f..65a38c0277 100644
--- a/org.springframework.core/src/main/java/org/springframework/core/convert/service/GenericConversionService.java
+++ b/org.springframework.core/src/main/java/org/springframework/core/convert/service/GenericConversionService.java
@@ -31,7 +31,6 @@ import org.springframework.core.convert.ConversionExecutor;
import org.springframework.core.convert.ConversionExecutorNotFoundException;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
-import org.springframework.core.convert.TypedValue;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterInfo;
import org.springframework.core.convert.converter.SuperConverter;
@@ -155,33 +154,32 @@ public class GenericConversionService implements ConversionService {
// implementing ConversionService
- public boolean canConvert(TypedValue source, TypeDescriptor targetType) {
+ public boolean canConvert(Object source, TypeDescriptor targetType) {
return false;
}
- public Object executeConversion(TypedValue source, TypeDescriptor targetType)
+ public Object executeConversion(Object source, TypeDescriptor targetType)
throws ConversionExecutorNotFoundException, ConversionException {
- Assert.notNull(source, "The source to convert from is required");
- if (source.isNull()) {
+ if (source == null) {
return null;
}
- return getConversionExecutor(source.getTypeDescriptor(), targetType).execute(source.getValue());
+ return getConversionExecutor(source.getClass(), targetType).execute(source);
}
- public Object executeConversion(String converterId, TypedValue source, TypeDescriptor targetType)
+ public Object executeConversion(String converterId, Object source, TypeDescriptor targetType)
throws ConversionExecutorNotFoundException, ConversionException {
- Assert.notNull(source, "The source to convert from is required");
- if (source.isNull()) {
+ if (source == null) {
return null;
}
- return getConversionExecutor(converterId, source.getTypeDescriptor(), targetType).execute(source.getValue());
+ return getConversionExecutor(converterId, source.getClass(), targetType).execute(source);
}
- public ConversionExecutor getConversionExecutor(TypeDescriptor sourceType, TypeDescriptor targetType)
+ public ConversionExecutor getConversionExecutor(Class sourceClass, TypeDescriptor targetType)
throws ConversionExecutorNotFoundException {
- Assert.notNull(sourceType, "The sourceType to convert from is required");
+ Assert.notNull(sourceClass, "The sourceType to convert from is required");
Assert.notNull(targetType, "The targetType to convert to is required");
// special handling for arrays since they are not indexable classes
+ TypeDescriptor sourceType = TypeDescriptor.valueOf(sourceClass);
if (sourceType.isArray()) {
if (targetType.isArray()) {
return new ArrayToArray(sourceType, targetType, this);
@@ -217,7 +215,7 @@ public class GenericConversionService implements ConversionService {
return new StaticSuperConversionExecutor(sourceType, targetType, superConverter);
}
if (parent != null) {
- return parent.getConversionExecutor(sourceType, targetType);
+ return parent.getConversionExecutor(sourceClass, targetType);
} else {
if (sourceType.isAssignableTo(targetType)) {
return new StaticConversionExecutor(sourceType, targetType, NoOpConverter.INSTANCE);
@@ -229,7 +227,7 @@ public class GenericConversionService implements ConversionService {
}
}
- public ConversionExecutor getConversionExecutor(String converterId, TypeDescriptor sourceType,
+ public ConversionExecutor getConversionExecutor(String converterId, Class sourceType,
TypeDescriptor targetType) throws ConversionExecutorNotFoundException {
throw new UnsupportedOperationException("Not yet implemented");
}
@@ -450,7 +448,7 @@ public class GenericConversionService implements ConversionService {
}
public ConversionExecutor getElementConverter(Class> sourceElementType, Class> targetElementType) {
- return getConversionExecutor(TypeDescriptor.valueOf(sourceElementType), TypeDescriptor
+ return getConversionExecutor(sourceElementType, TypeDescriptor
.valueOf(targetElementType));
}
diff --git a/org.springframework.core/src/test/java/org/springframework/core/convert/service/GenericConversionServiceTests.java b/org.springframework.core/src/test/java/org/springframework/core/convert/service/GenericConversionServiceTests.java
index 80ab88e9fd..fb206b4621 100644
--- a/org.springframework.core/src/test/java/org/springframework/core/convert/service/GenericConversionServiceTests.java
+++ b/org.springframework.core/src/test/java/org/springframework/core/convert/service/GenericConversionServiceTests.java
@@ -31,7 +31,6 @@ import org.springframework.core.convert.ConversionExecutionException;
import org.springframework.core.convert.ConversionExecutor;
import org.springframework.core.convert.ConversionExecutorNotFoundException;
import org.springframework.core.convert.TypeDescriptor;
-import org.springframework.core.convert.TypedValue;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.NumberToNumber;
import org.springframework.core.convert.converter.StringToEnum;
@@ -43,30 +42,30 @@ public class GenericConversionServiceTests extends TestCase {
public void testExecuteConversion() {
service.addConverter(new StringToInteger());
- assertEquals(new Integer(3), service.executeConversion(value("3"), type(Integer.class)));
+ assertEquals(new Integer(3), service.executeConversion("3", type(Integer.class)));
}
public void testExecuteConversionNullSource() {
- assertEquals(null, service.executeConversion(TypedValue.NULL, type(Integer.class)));
+ assertEquals(null, service.executeConversion(null, type(Integer.class)));
}
public void testConverterConversionForwardIndex() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(Integer.class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(Integer.class));
Integer three = (Integer) executor.execute("3");
assertEquals(3, three.intValue());
}
public void testConverterConversionReverseIndex() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(Integer.class), type(String.class));
+ ConversionExecutor executor = service.getConversionExecutor(Integer.class, type(String.class));
String threeString = (String) executor.execute(new Integer(3));
assertEquals("3", threeString);
}
public void testConversionExecutorNotFound() {
try {
- service.getConversionExecutor(type(String.class), type(Integer.class));
+ service.getConversionExecutor(String.class, type(Integer.class));
fail("Should have thrown an exception");
} catch (ConversionExecutorNotFoundException e) {
}
@@ -91,18 +90,18 @@ public class GenericConversionServiceTests extends TestCase {
public void testConversionCompatibleTypes() {
String source = "foo";
- assertSame(source, service.getConversionExecutor(type(String.class), type(String.class)).execute(source));
+ assertSame(source, service.getConversionExecutor(String.class, type(String.class)).execute(source));
}
public void testConversionExecutorNullArgument() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(Integer.class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(Integer.class));
assertNull(executor.execute(null));
}
public void testConversionExecutorWrongTypeArgument() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(Integer.class), type(String.class));
+ ConversionExecutor executor = service.getConversionExecutor(Integer.class, type(String.class));
try {
executor.execute("BOGUS");
fail("Should have failed");
@@ -121,7 +120,7 @@ public class GenericConversionServiceTests extends TestCase {
return target.toString();
}
});
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(Integer.class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(Integer.class));
Integer result = (Integer) executor.execute("3");
assertEquals(new Integer(3), result);
}
@@ -137,7 +136,7 @@ public class GenericConversionServiceTests extends TestCase {
}
});
try {
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(Integer.class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(Integer.class));
fail("Should have failed");
} catch (ConversionExecutorNotFoundException e) {
@@ -146,14 +145,14 @@ public class GenericConversionServiceTests extends TestCase {
public void testConversionObjectToPrimitive() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(int.class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(int.class));
Integer three = (Integer) executor.execute("3");
assertEquals(3, three.intValue());
}
public void testConversionArrayToArray() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(String[].class), type(Integer[].class));
+ ConversionExecutor executor = service.getConversionExecutor(String[].class, type(Integer[].class));
Integer[] result = (Integer[]) executor.execute(new String[] { "1", "2", "3" });
assertEquals(new Integer(1), result[0]);
assertEquals(new Integer(2), result[1]);
@@ -162,7 +161,7 @@ public class GenericConversionServiceTests extends TestCase {
public void testConversionArrayToPrimitiveArray() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(String[].class), type(int[].class));
+ ConversionExecutor executor = service.getConversionExecutor(String[].class, type(int[].class));
int[] result = (int[]) executor.execute(new String[] { "1", "2", "3" });
assertEquals(1, result[0]);
assertEquals(2, result[1]);
@@ -170,7 +169,7 @@ public class GenericConversionServiceTests extends TestCase {
}
public void testConversionArrayToListInterface() {
- ConversionExecutor executor = service.getConversionExecutor(type(String[].class), type(List.class));
+ ConversionExecutor executor = service.getConversionExecutor(String[].class, type(List.class));
List result = (List) executor.execute(new String[] { "1", "2", "3" });
assertEquals("1", result.get(0));
assertEquals("2", result.get(1));
@@ -181,7 +180,7 @@ public class GenericConversionServiceTests extends TestCase {
public void testConversionArrayToListGenericTypeConversion() throws Exception {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(String[].class), new TypeDescriptor(getClass().getDeclaredField("genericList")));
+ ConversionExecutor executor = service.getConversionExecutor(String[].class, new TypeDescriptor(getClass().getDeclaredField("genericList")));
List result = (List) executor.execute(new String[] { "1", "2", "3" });
assertEquals(new Integer("1"), result.get(0));
assertEquals(new Integer("2"), result.get(1));
@@ -189,7 +188,7 @@ public class GenericConversionServiceTests extends TestCase {
}
public void testConversionArrayToListImpl() {
- ConversionExecutor executor = service.getConversionExecutor(type(String[].class), type(LinkedList.class));
+ ConversionExecutor executor = service.getConversionExecutor(String[].class, type(LinkedList.class));
LinkedList result = (LinkedList) executor.execute(new String[] { "1", "2", "3" });
assertEquals("1", result.get(0));
assertEquals("2", result.get(1));
@@ -198,14 +197,14 @@ public class GenericConversionServiceTests extends TestCase {
public void testConversionArrayToAbstractList() {
try {
- service.getConversionExecutor(type(String[].class), type(AbstractList.class));
+ service.getConversionExecutor(String[].class, type(AbstractList.class));
} catch (IllegalArgumentException e) {
}
}
public void testConversionListToArray() {
- ConversionExecutor executor = service.getConversionExecutor(type(Collection.class), type(String[].class));
+ ConversionExecutor executor = service.getConversionExecutor(Collection.class, type(String[].class));
List list = new ArrayList();
list.add("1");
list.add("2");
@@ -218,7 +217,7 @@ public class GenericConversionServiceTests extends TestCase {
public void testConversionListToArrayWithComponentConversion() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(Collection.class), type(Integer[].class));
+ ConversionExecutor executor = service.getConversionExecutor(Collection.class, type(Integer[].class));
List list = new ArrayList();
list.add("1");
list.add("2");
@@ -232,7 +231,7 @@ public class GenericConversionServiceTests extends TestCase {
@Ignore
@Test
public void conversionObjectToArray() {
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(String[].class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(String[].class));
String[] result = (String[]) executor.execute("1,2,3");
assertEquals(1, result.length);
assertEquals("1,2,3", result[0]);
@@ -242,7 +241,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void conversionObjectToArrayWithElementConversion() {
service.addConverter(new StringToInteger());
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(Integer[].class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(Integer[].class));
Integer[] result = (Integer[]) executor.execute("123");
assertEquals(1, result.length);
assertEquals(new Integer(123), result[0]);
@@ -254,19 +253,19 @@ public class GenericConversionServiceTests extends TestCase {
public void testSuperConverterConversionForwardIndex() {
service.addConverter(new StringToEnum());
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(FooEnum.class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(FooEnum.class));
assertEquals(FooEnum.BAR, executor.execute("BAR"));
}
public void testSuperTwoWayConverterConversionReverseIndex() {
service.addConverter(new StringToEnum());
- ConversionExecutor executor = service.getConversionExecutor(type(FooEnum.class), type(String.class));
+ ConversionExecutor executor = service.getConversionExecutor(FooEnum.class, type(String.class));
assertEquals("BAR", executor.execute(FooEnum.BAR));
}
public void testSuperConverterConversionNotConvertibleAbstractType() {
service.addConverter(new StringToEnum());
- ConversionExecutor executor = service.getConversionExecutor(type(String.class), type(Enum.class));
+ ConversionExecutor executor = service.getConversionExecutor(String.class, type(Enum.class));
try {
executor.execute("WHATEV");
fail("Should have failed");
@@ -298,7 +297,7 @@ public class GenericConversionServiceTests extends TestCase {
return 0;
}
};
- ConversionExecutor executor = service.getConversionExecutor(type(Integer.class), type(customNumber.getClass()));
+ ConversionExecutor executor = service.getConversionExecutor(Integer.class, type(customNumber.getClass()));
try {
executor.execute(3);
fail("Should have failed");
@@ -311,7 +310,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionForwardIndex() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(String.class), type(Principal.class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", String.class, type(Principal.class));
assertEquals("keith", ((Principal) executor.execute("keith")).getName());
}
@@ -319,7 +318,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionReverseIndex() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(Principal.class), type(String.class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, type(String.class));
assertEquals("keith", executor.execute(new Principal() {
public String getName() {
return "keith";
@@ -331,7 +330,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionForSameType() {
service.addConverter("trimmer", new Trimmer());
- ConversionExecutor executor = service.getConversionExecutor("trimmer", type(String.class), type(String.class));
+ ConversionExecutor executor = service.getConversionExecutor("trimmer", String.class, type(String.class));
assertEquals("a string", executor.execute("a string "));
}
@@ -340,7 +339,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupNotCompatibleSource() {
service.addConverter("trimmer", new Trimmer());
try {
- service.getConversionExecutor("trimmer", type(Object.class), type(String.class));
+ service.getConversionExecutor("trimmer", Object.class, type(String.class));
fail("Should have failed");
} catch (ConversionException e) {
@@ -352,7 +351,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupNotCompatibleTarget() {
service.addConverter("trimmer", new Trimmer());
try {
- service.getConversionExecutor("trimmer", type(String.class), type(Object.class));
+ service.getConversionExecutor("trimmer", String.class, type(Object.class));
} catch (ConversionException e) {
}
@@ -363,7 +362,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupNotCompatibleTargetReverse() {
service.addConverter("princy", new CustomTwoWayConverter());
try {
- service.getConversionExecutor("princy", type(Principal.class), type(Integer.class));
+ service.getConversionExecutor("princy", Principal.class, type(Integer.class));
} catch (ConversionException e) {
}
@@ -373,7 +372,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionArrayToArray() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(String[].class), type(Principal[].class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", String[].class, type(Principal[].class));
Principal[] p = (Principal[]) executor.execute(new String[] { "princy1", "princy2" });
assertEquals("princy1", p[0].getName());
assertEquals("princy2", p[1].getName());
@@ -383,7 +382,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionArrayToArrayReverse() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(Principal[].class), type(String[].class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", Principal[].class, type(String[].class));
final Principal princy1 = new Principal() {
public String getName() {
return "princy1";
@@ -404,7 +403,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupArrayToArrayBogusSource() {
service.addConverter("princy", new CustomTwoWayConverter());
try {
- service.getConversionExecutor("princy", type(Integer[].class), type(Principal[].class));
+ service.getConversionExecutor("princy", Integer[].class, type(Principal[].class));
fail("Should have failed");
} catch (ConversionExecutorNotFoundException e) {
}
@@ -415,7 +414,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupArrayToArrayBogusTarget() {
service.addConverter("princy", new CustomTwoWayConverter());
try {
- service.getConversionExecutor("princy", type(Principal[].class), type(Integer[].class));
+ service.getConversionExecutor("princy", Principal[].class, type(Integer[].class));
} catch (ConversionExecutorNotFoundException e) {
}
@@ -425,7 +424,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionArrayToCollection() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(String[].class), type(List.class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", String[].class, type(List.class));
List list = (List) executor.execute(new String[] { "princy1", "princy2" });
assertEquals("princy1", ((Principal) list.get(0)).getName());
assertEquals("princy2", ((Principal) list.get(1)).getName());
@@ -435,7 +434,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionArrayToCollectionReverse() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(Principal[].class), type(List.class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", Principal[].class, type(List.class));
final Principal princy1 = new Principal() {
public String getName() {
return "princy1";
@@ -456,7 +455,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupArrayToCollectionBogusSource() {
service.addConverter("princy", new CustomTwoWayConverter());
try {
- service.getConversionExecutor("princy", type(Integer[].class), type(List.class));
+ service.getConversionExecutor("princy", Integer[].class, type(List.class));
fail("Should have failed");
} catch (ConversionExecutorNotFoundException e) {
@@ -467,7 +466,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterLookupCollectionToArray() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(List.class), type(Principal[].class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", List.class, type(Principal[].class));
List princyList = new ArrayList();
princyList.add("princy1");
princyList.add("princy2");
@@ -480,7 +479,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterLookupCollectionToArrayReverse() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(List.class), type(String[].class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", List.class, type(String[].class));
final Principal princy1 = new Principal() {
public String getName() {
return "princy1";
@@ -504,7 +503,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupCollectionToArrayBogusTarget() {
service.addConverter("princy", new CustomTwoWayConverter());
try {
- service.getConversionExecutor("princy", type(List.class), type(Integer[].class));
+ service.getConversionExecutor("princy", List.class, type(Integer[].class));
fail("Should have failed");
} catch (ConversionExecutorNotFoundException e) {
@@ -515,7 +514,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionObjectToArray() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(String.class), type(Principal[].class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", String.class, type(Principal[].class));
Principal[] p = (Principal[]) executor.execute("princy1");
assertEquals("princy1", p[0].getName());
}
@@ -524,7 +523,7 @@ public class GenericConversionServiceTests extends TestCase {
@Test
public void customConverterConversionObjectToArrayReverse() {
service.addConverter("princy", new CustomTwoWayConverter());
- ConversionExecutor executor = service.getConversionExecutor("princy", type(Principal.class), type(String[].class));
+ ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, type(String[].class));
final Principal princy1 = new Principal() {
public String getName() {
return "princy1";
@@ -539,7 +538,7 @@ public class GenericConversionServiceTests extends TestCase {
public void customConverterLookupObjectToArrayBogusSource() {
service.addConverter("princy", new CustomTwoWayConverter());
try {
- service.getConversionExecutor("princy", type(Integer.class), type(Principal[].class));
+ service.getConversionExecutor("princy", Integer.class, type(Principal[].class));
fail("Should have failed");
} catch (ConversionExecutorNotFoundException e) {
@@ -576,11 +575,7 @@ public class GenericConversionServiceTests extends TestCase {
public void testSuperTwoWayConverterConverterAdaption() {
service.addConverter(GenericConversionService.converterFor(String.class, FooEnum.class, new StringToEnum()));
- assertEquals(FooEnum.BAR, service.executeConversion(value("BAR"), type(FooEnum.class)));
- }
-
- private TypedValue value(Object obj) {
- return new TypedValue(obj);
+ assertEquals(FooEnum.BAR, service.executeConversion("BAR", type(FooEnum.class)));
}
private TypeDescriptor type(Class> clazz) {