@SuppressWarnings("unchecked") public static <T> T fromJsonIntoClone(String jsonAsString, T pojo) throws JsonException { Map<String, Object> incoming = JsonUtils.fromJsonToMap(jsonAsString); Map<String, Object> existing = JsonUtils.mapify(pojo); existing.putAll(incoming); T clone = (T) unmapify(existing, pojo.getClass()); return clone; }
// adding cast for java compiler @SuppressWarnings("unchecked") public static <T> T fromMapInto(Map<String, ?> map, T pojo) throws JsonException { try { String jsonAsString = JsonUtils.toJson(map); return (T) m.readerForUpdating(pojo).readValue(jsonAsString); } catch (JsonProcessingException e) { throw new JsonException(e); } catch (IOException e) { throw new JsonException(e); } }