From c54caf308c3f7d4a6088cf3085c2caa9617e0458 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Mon, 25 Oct 2021 20:28:16 +0200 Subject: [PATCH] Deprecate `Gson.excluder()` exposing internal `Excluder` class (#1986) --- gson/src/main/java/com/google/gson/Gson.java | 22 +++++++++++++++++++ .../test/java/com/google/gson/GsonTest.java | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java index 1511bbb178..ef7b875195 100644 --- a/gson/src/main/java/com/google/gson/Gson.java +++ b/gson/src/main/java/com/google/gson/Gson.java @@ -299,18 +299,40 @@ public GsonBuilder newBuilder() { return new GsonBuilder(this); } + /** + * @deprecated This method by accident exposes an internal Gson class; it might be removed in a + * future version. + */ + @Deprecated public Excluder excluder() { return excluder; } + /** + * Returns the field naming strategy used by this Gson instance. + * + * @see GsonBuilder#setFieldNamingStrategy(FieldNamingStrategy) + */ public FieldNamingStrategy fieldNamingStrategy() { return fieldNamingStrategy; } + /** + * Returns whether this Gson instance is serializing JSON object properties with + * {@code null} values, or just omits them. + * + * @see GsonBuilder#serializeNulls() + */ public boolean serializeNulls() { return serializeNulls; } + /** + * Returns whether this Gson instance produces JSON output which is + * HTML-safe, that means all HTML characters are escaped. + * + * @see GsonBuilder#disableHtmlEscaping() + */ public boolean htmlSafe() { return htmlSafe; } diff --git a/gson/src/test/java/com/google/gson/GsonTest.java b/gson/src/test/java/com/google/gson/GsonTest.java index d537f7ad5b..c6cc4d5426 100644 --- a/gson/src/test/java/com/google/gson/GsonTest.java +++ b/gson/src/test/java/com/google/gson/GsonTest.java @@ -55,7 +55,7 @@ public void testOverridesDefaultExcluder() { new ArrayList(), new ArrayList(), CUSTOM_OBJECT_TO_NUMBER_STRATEGY, CUSTOM_NUMBER_TO_NUMBER_STRATEGY); - assertEquals(CUSTOM_EXCLUDER, gson.excluder()); + assertEquals(CUSTOM_EXCLUDER, gson.excluder); assertEquals(CUSTOM_FIELD_NAMING_STRATEGY, gson.fieldNamingStrategy()); assertEquals(true, gson.serializeNulls()); assertEquals(false, gson.htmlSafe());