Guava's got a method for that.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6698 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2011-08-26 13:05:39 +00:00
parent d2fcc311b5
commit 02977a154e
2 changed files with 2 additions and 27 deletions
@@ -274,32 +274,6 @@ public class ActionScriptUtils
return false;
}
/**
* Returns the primitive (unboxed) counterpart of a class, or the same class if it isn't a boxed
* type.
*/
public static Class<?> toPrimitiveType (Class<?> cclass)
{
if (Boolean.class == cclass) {
return Boolean.TYPE;
} else if (Character.class == cclass) {
return Character.TYPE;
} else if (Byte.class == cclass) {
return Byte.TYPE;
} else if (Short.class == cclass) {
return Short.TYPE;
} else if (Integer.class == cclass) {
return Integer.TYPE;
} else if (Long.class == cclass) {
return Long.TYPE;
} else if (Float.class == cclass) {
return Float.TYPE;
} else if (Double.class == cclass) {
return Double.TYPE;
}
return cclass;
}
/** Returns if the given class is an implementation of Map that doesn't know about Streaming */
protected static boolean isNaiveMap (Class<?> type)
{
@@ -33,6 +33,7 @@ import org.apache.tools.ant.Project;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.primitives.Primitives;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.io.Files;
@@ -189,7 +190,7 @@ public class GenActionScriptStreamableTask extends GenTask
for (Type param : ((ParameterizedType) genType).getActualTypeArguments()) {
if (param instanceof Class) {
// Convert any box classes to primitives to avoid having to import them
Class<?> primitive = ActionScriptUtils.toPrimitiveType((Class<?>) param);
Class<?> primitive = Primitives.unwrap((Class<?>) param);
parameters.add(ActionScriptUtils.addImportAndGetShortType(
primitive, false, imports));
}