diff options
Diffstat (limited to 'src/org/traccar/web/JsonConverter.java')
-rw-r--r-- | src/org/traccar/web/JsonConverter.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/org/traccar/web/JsonConverter.java b/src/org/traccar/web/JsonConverter.java index 38721db61..2ef61fb13 100644 --- a/src/org/traccar/web/JsonConverter.java +++ b/src/org/traccar/web/JsonConverter.java @@ -34,7 +34,6 @@ import javax.json.JsonValue; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.ISODateTimeFormat; -import org.traccar.helper.Clazz; import org.traccar.helper.Log; import org.traccar.model.Factory; import org.traccar.model.MiscFormatter; @@ -44,6 +43,14 @@ public final class JsonConverter { private JsonConverter() { } + private static <T> T newClassInstance(Class<T> clazz) { + try { + return clazz.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + throw new IllegalArgumentException(); + } + } + private static final DateTimeFormatter DATE_FORMAT = ISODateTimeFormat.dateTime(); public static Date parseDate(String value) { @@ -69,7 +76,7 @@ public final class JsonConverter { } public static <T> T objectFromJson(JsonObject json, Class<T> clazz) { - T object = Clazz.newInstance(clazz); + T object = newClassInstance(clazz); Method[] methods = object.getClass().getMethods(); return objectFromJson(json, object, methods); } |