@Test public void test_serialize_simple_types() { Stream.of( tuple2(Integer.MAX_VALUE, "" + 0x7fffffff), tuple2(Long.MAX_VALUE, "" + 0x7fffffffffffffffL), tuple2(Float.MAX_VALUE, "" + Float.MAX_VALUE), tuple2(Double.MAX_VALUE, "" + Double.MAX_VALUE), tuple2((byte) 1, "1"), tuple2(true, "true"), tuple2(TimeUnit.HOURS, "\"HOURS\"") ).forEach(tuple -> assertThat("Serializing: " + tuple.t1, codec.serialize(tuple.t1), is(equalTo(tuple.t2)))); }
@Override public String serialize(Object o) throws DiagnosticCodecException { requireNonNull(o); try { return objectMapper.writeValueAsString(o); } catch (JsonProcessingException | RuntimeException e) { throw new DiagnosticCodecException(e); } }
JsonDiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public String serialize(Object o) throws DiagnosticCodecException { requireNonNull(o); try { return objectMapper.writeValueAsString(o); } catch (JsonProcessingException | RuntimeException e) { throw new DiagnosticCodecException(e); } } }
JsonDiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public String serialize(Object o) throws DiagnosticCodecException { requireNonNull(o); try { return objectMapper.writeValueAsString(o); } catch (JsonProcessingException | RuntimeException e) { throw new DiagnosticCodecException(e); } } JsonDiagnosticCodec(ObjectMapperFactory objectMapperFactory); }
JsonDiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public String serialize(Object o) throws DiagnosticCodecException { requireNonNull(o); try { return objectMapper.writeValueAsString(o); } catch (JsonProcessingException | RuntimeException e) { throw new DiagnosticCodecException(e); } } JsonDiagnosticCodec(ObjectMapperFactory objectMapperFactory); @Override String serialize(Object o); @Override T deserialize(String json, Class<T> target); @Override String toString(); }
JsonDiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public String serialize(Object o) throws DiagnosticCodecException { requireNonNull(o); try { return objectMapper.writeValueAsString(o); } catch (JsonProcessingException | RuntimeException e) { throw new DiagnosticCodecException(e); } } JsonDiagnosticCodec(ObjectMapperFactory objectMapperFactory); @Override String serialize(Object o); @Override T deserialize(String json, Class<T> target); @Override String toString();  }