diff --git a/spring-core/src/main/java/org/springframework/core/convert/converter/ConditionalConverter.java b/spring-core/src/main/java/org/springframework/core/convert/converter/ConditionalConverter.java
index 94aacd6261f..964139e0a2e 100644
--- a/spring-core/src/main/java/org/springframework/core/convert/converter/ConditionalConverter.java
+++ b/spring-core/src/main/java/org/springframework/core/convert/converter/ConditionalConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2014 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.
@@ -26,11 +26,10 @@ import org.springframework.core.convert.TypeDescriptor;
*
Often used to selectively match custom conversion logic based on the presence of a
* field or class-level characteristic, such as an annotation or method. For example, when
* converting from a String field to a Date field, an implementation might return
- *
* {@code true} if the target field has also been annotated with {@code @DateTimeFormat}.
*
- *
As another example, when converting from a String field to an {@code Account} field, an
- * implementation might return {@code true} if the target Account class defines a
+ *
As another example, when converting from a String field to an {@code Account} field,
+ * an implementation might return {@code true} if the target Account class defines a
* {@code public static findAccount(String)} method.
*
* @author Phillip Webb
@@ -46,10 +45,10 @@ public interface ConditionalConverter {
/**
* Should the conversion from {@code sourceType} to {@code targetType} currently under
* consideration be selected?
- *
* @param sourceType the type descriptor of the field we are converting from
* @param targetType the type descriptor of the field we are converting to
* @return true if conversion should be performed, false otherwise
*/
boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType);
+
}
diff --git a/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java b/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java
index 68261559898..5258497be22 100644
--- a/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java
+++ b/spring-core/src/main/java/org/springframework/core/convert/converter/GenericConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2014 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.
@@ -16,11 +16,11 @@
package org.springframework.core.convert.converter;
+import java.util.Set;
+
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.util.Assert;
-import java.util.Set;
-
/**
* Generic converter interface for converting between two or more types.
*
@@ -104,13 +104,17 @@ public interface GenericConverter {
}
ConvertiblePair other = (ConvertiblePair) obj;
return this.sourceType.equals(other.sourceType) && this.targetType.equals(other.targetType);
-
}
@Override
public int hashCode() {
return this.sourceType.hashCode() * 31 + this.targetType.hashCode();
}
+
+ @Override
+ public String toString() {
+ return this.sourceType.getName() + " -> " + this.targetType.getName();
+ }
}
}
diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
index 2f4f4f1ba4b..97ffbbda258 100644
--- a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
+++ b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2014 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.
@@ -83,12 +83,12 @@ public class GenericConversionService implements ConfigurableConversionService {
GenericConverter.ConvertiblePair typeInfo = getRequiredTypeInfo(converter, Converter.class);
Assert.notNull(typeInfo, "Unable to the determine sourceType and targetType " +
" which your Converter converts between; declare these generic types.");
- addConverter(new ConverterAdapter(typeInfo, converter));
+ addConverter(new ConverterAdapter(converter, typeInfo));
}
public void addConverter(Class> sourceType, Class> targetType, Converter, ?> converter) {
GenericConverter.ConvertiblePair typeInfo = new GenericConverter.ConvertiblePair(sourceType, targetType);
- addConverter(new ConverterAdapter(typeInfo, converter));
+ addConverter(new ConverterAdapter(converter, typeInfo));
}
public void addConverter(GenericConverter converter) {
@@ -103,7 +103,7 @@ public class GenericConversionService implements ConfigurableConversionService {
"targetRangeType R which your ConverterFactory converts between; " +
"declare these generic types.");
}
- addConverter(new ConverterFactoryAdapter(typeInfo, converterFactory));
+ addConverter(new ConverterFactoryAdapter(converterFactory, typeInfo));
}
public void removeConvertible(Class> sourceType, Class> targetType) {
@@ -114,14 +114,13 @@ public class GenericConversionService implements ConfigurableConversionService {
// implementing ConversionService
public boolean canConvert(Class> sourceType, Class> targetType) {
- Assert.notNull(targetType, "The targetType to convert to cannot be null");
- return canConvert(sourceType != null ?
- TypeDescriptor.valueOf(sourceType) : null,
+ Assert.notNull(targetType, "targetType to convert to cannot be null");
+ return canConvert((sourceType != null ? TypeDescriptor.valueOf(sourceType) : null),
TypeDescriptor.valueOf(targetType));
}
public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) {
- Assert.notNull(targetType,"The targetType to convert to cannot be null");
+ Assert.notNull(targetType, "targetType to convert to cannot be null");
if (sourceType == null) {
return true;
}
@@ -189,6 +188,7 @@ public class GenericConversionService implements ConfigurableConversionService {
return convert(source, TypeDescriptor.forObject(source), targetType);
}
+ @Override
public String toString() {
return this.converters.toString();
}
@@ -297,17 +297,15 @@ public class GenericConversionService implements ConfigurableConversionService {
@SuppressWarnings("unchecked")
private final class ConverterAdapter implements ConditionalGenericConverter {
- private final ConvertiblePair typeInfo;
-
private final Converter