From 9267ac29bad105a09ab28794790a370b2b988b19 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 16 Apr 2012 11:08:36 -0700 Subject: [PATCH] allow chef to extend this --- .../json/internal/NullHackJsonLiteralAdapter.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java b/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java index 6efba01b76..e37815c43f 100644 --- a/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java +++ b/core/src/main/java/org/jclouds/json/internal/NullHackJsonLiteralAdapter.java @@ -72,7 +72,7 @@ public abstract class NullHackJsonLiteralAdapter extends TypeAdapter { try { // we are using an implementation hack which depends on replacing null with the raw json // supplied as a parameter. In this case, we must ensure we indeed serialize nulls. - NullReplacingWriter nullReplacingWriter = new NullReplacingWriter(writer, value.toString()); + NullReplacingWriter nullReplacingWriter = new NullReplacingWriter(writer, toString(value)); setWriter(jsonWriter, nullReplacingWriter); jsonWriter.setSerializeNulls(true); jsonWriter.nullValue(); @@ -83,7 +83,11 @@ public abstract class NullHackJsonLiteralAdapter extends TypeAdapter { } - private Writer getWriter(JsonWriter arg0) { + protected String toString(L value) { + return value.toString(); + } + + protected Writer getWriter(JsonWriter arg0) { try { return Writer.class.cast(outField.get(arg0)); } catch (IllegalAccessException e) { @@ -99,7 +103,7 @@ public abstract class NullHackJsonLiteralAdapter extends TypeAdapter { } } - private final class NullReplacingWriter extends Writer { + public final class NullReplacingWriter extends Writer { private final Writer delegate; private final String nullReplacement;