Author: adrianc
Date: Tue Nov 24 19:26:20 2009
New Revision: 883827
URL:
http://svn.apache.org/viewvc?rev=883827&view=revLog:
Eliminated unnecessary casts.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java?rev=883827&r1=883826&r2=883827&view=diff==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/conversion/Converters.java Tue Nov 24 19:26:20 2009
@@ -31,6 +31,7 @@
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.ObjectType;
+import org.ofbiz.base.util.UtilGenerics;
/** A <code>Converter</code> factory and repository. */
public class Converters {
@@ -75,7 +76,6 @@
* @return A matching <code>Converter</code> instance
* @throws ClassNotFoundException
*/
- @SuppressWarnings("unchecked")
public static <S, T> Converter<S, T> getConverter(Class<S> sourceClass, Class<T> targetClass) throws ClassNotFoundException {
String key = sourceClass.getName().concat(DELIMITER).concat(targetClass.getName());
if (Debug.verboseOn()) {
@@ -89,13 +89,13 @@
for (Converter<?, ?> value : values) {
if (value.canConvert(sourceClass, targetClass)) {
converterMap.put(key, value);
- return (Converter<S, T>) value;
+ return UtilGenerics.cast(value);
}
}
// Null converter must be checked last
if (nullConverter.canConvert(sourceClass, targetClass)) {
converterMap.put(key, nullConverter);
- return (Converter<S, T>) nullConverter;
+ return UtilGenerics.cast(nullConverter);
}
noConversions.add(key);
Debug.logWarning("*** No converter found, converting from " +
@@ -106,7 +106,7 @@
}
throw new ClassNotFoundException("No converter found for " + key);
}
- return (Converter<S, T>) result;
+ return UtilGenerics.cast(result);
}
/** Load all classes that implement <code>Converter</code> and are