mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Use string switch/case in IntrospectionProvider
This commit is contained in:
parent
57c1b57b7c
commit
90ccd6c40e
1 changed files with 9 additions and 13 deletions
|
@ -117,25 +117,21 @@ public class IntrospectionProvider{
|
|||
* @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;
|
||||
}
|
||||
if (type.getName().equals("boolean")) {
|
||||
case "boolean":
|
||||
return Boolean.valueOf(value);
|
||||
}
|
||||
if (type.getName().equals("int")) {
|
||||
case "int":
|
||||
return Integer.valueOf(value);
|
||||
}
|
||||
if (type.getName().equals("long")) {
|
||||
case "long":
|
||||
return Long.valueOf(value);
|
||||
}
|
||||
if (type.getName().equals("float")) {
|
||||
case "float":
|
||||
return Float.valueOf(value);
|
||||
}
|
||||
if (type.getName().equals("double")) {
|
||||
case "double":
|
||||
return Double.valueOf(value);
|
||||
}
|
||||
if (type.getName().equals("java.lang.Class")) {
|
||||
case "java.lang.Class":
|
||||
return Class.forName(value);
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue