@Override public DbRepairJobState decodeFromString(String infoStr) throws FatalCoordinatorException { try { mapper.readerForUpdating(this).readValue(infoStr); return this; } catch (IOException e) { log.error("Failed to decode data string", e); throw CoordinatorException.fatals.decodingError(e.getMessage()); } }
@SuppressWarnings("unchecked") public static <T> T fromJsonInto(InputStream jsonStream, T pojo) throws JsonException { try { return (T) m.readerForUpdating(pojo).readValue(jsonStream); } catch (JsonProcessingException e) { throw new JsonException(e); } catch (IOException e) { throw new JsonException(e); } }
// 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); } }