Resolve itest runbundles for Gson and Commons Lang upgrades and fix JsonParser deprecations (#10345)

* Resolve itest runbundles for Gson and Commons Lang upgrades
* Fix JsonParser deprecations too
* Fix feature verification

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-03-18 12:15:15 +01:00
committed by GitHub
parent 009208adee
commit 580f293766
86 changed files with 206 additions and 215 deletions

View File

@@ -44,7 +44,6 @@ import org.openhab.core.types.UnDefType;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.internal.Primitives;
/**
* {@link ShellyUtils} provides general utility functions
@@ -78,7 +77,7 @@ public class ShellyUtils {
}
if (classOfT.isInstance(json)) {
return Primitives.wrap(classOfT).cast(json);
return wrap(classOfT).cast(json);
} else if (json.isEmpty()) { // update GSON might return null
throw new ShellyApiException(PRE + className + "from empty JSON");
} else {
@@ -97,6 +96,37 @@ public class ShellyUtils {
}
}
private static <T> Class<T> wrap(Class<T> type) {
if (type == int.class) {
return (Class<T>) Integer.class;
}
if (type == float.class) {
return (Class<T>) Float.class;
}
if (type == byte.class) {
return (Class<T>) Byte.class;
}
if (type == double.class) {
return (Class<T>) Double.class;
}
if (type == long.class) {
return (Class<T>) Long.class;
}
if (type == char.class) {
return (Class<T>) Character.class;
}
if (type == boolean.class) {
return (Class<T>) Boolean.class;
}
if (type == short.class) {
return (Class<T>) Short.class;
}
if (type == void.class) {
return (Class<T>) Void.class;
}
return type;
}
public static String mkChannelId(String group, String channel) {
return group + "#" + channel;
}