// 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); } }
@SuppressWarnings("unchecked") public static <T> T fromMapIntoClone(Map<String, ?> map, T pojo) throws JsonException { String jsonAsString = JsonUtils.toJson(map); 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; }