1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 14:02:06 +01:00

Use string switch/case in IntrospectionProvider

This commit is contained in:
Florian Schmaus 2015-02-12 13:36:14 +01:00
parent 57c1b57b7c
commit 90ccd6c40e

View file

@ -117,25 +117,21 @@ public class IntrospectionProvider{
* @throws ClassNotFoundException * @throws ClassNotFoundException
*/ */
private static Object decode(Class<?> type, String value) throws ClassNotFoundException { private static Object decode(Class<?> type, String value) throws ClassNotFoundException {
if (type.getName().equals("java.lang.String")) { String name = type.getName();
switch (name) {
case "java.lang.String":
return value; return value;
} case "boolean":
if (type.getName().equals("boolean")) {
return Boolean.valueOf(value); return Boolean.valueOf(value);
} case "int":
if (type.getName().equals("int")) {
return Integer.valueOf(value); return Integer.valueOf(value);
} case "long":
if (type.getName().equals("long")) {
return Long.valueOf(value); return Long.valueOf(value);
} case "float":
if (type.getName().equals("float")) {
return Float.valueOf(value); return Float.valueOf(value);
} case "double":
if (type.getName().equals("double")) {
return Double.valueOf(value); return Double.valueOf(value);
} case "java.lang.Class":
if (type.getName().equals("java.lang.Class")) {
return Class.forName(value); return Class.forName(value);
} }
return null; return null;