@Test void should_serialize_null_as_null() throws IOException { serializer.serialize(null, gen, provider); verify(converter, never()).convert(any()); verify(gen).writeNull(); }
@Override public void serialize(Instant instant, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { try { if (instant == null) { gen.writeNull(); } else { gen.writeString(converter.convert(instant)); } } catch (Exception e) { throw new JsonGenerationException("Could not serialize instant: " + instant, e, gen); } }
InstantSerializer extends StdSerializer<Instant> { @Override public void serialize(Instant instant, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { try { if (instant == null) { gen.writeNull(); } else { gen.writeString(converter.convert(instant)); } } catch (Exception e) { throw new JsonGenerationException("Could not serialize instant: " + instant, e, gen); } } }
InstantSerializer extends StdSerializer<Instant> { @Override public void serialize(Instant instant, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { try { if (instant == null) { gen.writeNull(); } else { gen.writeString(converter.convert(instant)); } } catch (Exception e) { throw new JsonGenerationException("Could not serialize instant: " + instant, e, gen); } } InstantSerializer(Converter<Instant, String> converter); }
InstantSerializer extends StdSerializer<Instant> { @Override public void serialize(Instant instant, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { try { if (instant == null) { gen.writeNull(); } else { gen.writeString(converter.convert(instant)); } } catch (Exception e) { throw new JsonGenerationException("Could not serialize instant: " + instant, e, gen); } } InstantSerializer(Converter<Instant, String> converter); @Override void serialize(Instant instant, JsonGenerator gen, SerializerProvider serializerProvider); }
InstantSerializer extends StdSerializer<Instant> { @Override public void serialize(Instant instant, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { try { if (instant == null) { gen.writeNull(); } else { gen.writeString(converter.convert(instant)); } } catch (Exception e) { throw new JsonGenerationException("Could not serialize instant: " + instant, e, gen); } } InstantSerializer(Converter<Instant, String> converter); @Override void serialize(Instant instant, JsonGenerator gen, SerializerProvider serializerProvider);  }