### Question:
JsonAdapter { @CheckReturnValue public final JsonAdapter<T> serializeNulls() { final JsonAdapter<T> delegate = this; return new JsonAdapter<T>() { @Override public @Nullable T fromJson(JsonReader reader) throws IOException { return delegate.fromJson(reader); } @Override public void toJson(JsonWriter writer, @Nullable T value) throws IOException { boolean serializeNulls = writer.getSerializeNulls(); writer.setSerializeNulls(true); try { delegate.toJson(writer, value); } finally { writer.setSerializeNulls(serializeNulls); } } @Override boolean isLenient() { return delegate.isLenient(); } @Override public String toString() { return delegate + ".serializeNulls()"; } }; }  @CheckReturnValue abstract @Nullable T fromJson(JsonReader reader); @CheckReturnValue final @Nullable T fromJson(BufferedSource source); @CheckReturnValue final @Nullable T fromJson(String string); abstract void toJson(JsonWriter writer, @Nullable T value); final void toJson(BufferedSink sink, @Nullable T value); @CheckReturnValue final String toJson(@Nullable T value); @CheckReturnValue final @Nullable Object toJsonValue(@Nullable T value); @CheckReturnValue final @Nullable T fromJsonValue(@Nullable Object value); @CheckReturnValue final JsonAdapter<T> serializeNulls(); @CheckReturnValue final JsonAdapter<T> nullSafe(); @CheckReturnValue final JsonAdapter<T> nonNull(); @CheckReturnValue final JsonAdapter<T> lenient(); @CheckReturnValue final JsonAdapter<T> failOnUnknown(); @CheckReturnValue JsonAdapter<T> indent(final String indent);  }### Answer:
@Test public void serializeNulls() throws Exception { JsonAdapter<Map<String, String>> serializeNulls = new JsonAdapter<Map<String, String>>() { @Override public Map<String, String> fromJson(JsonReader reader) throws IOException { throw new AssertionError(); } @Override public void toJson(JsonWriter writer, Map<String, String> map) throws IOException { writer.beginObject(); for (Map.Entry<String, String> entry : map.entrySet()) { writer.name(entry.getKey()).value(entry.getValue()); } writer.endObject(); } }.serializeNulls(); JsonWriter writer = factory.newWriter(); serializeNulls.toJson(writer, Collections.<String, String>singletonMap("a", null)); assertThat(factory.json()).isEqualTo("{\"a\":null}"); }