Skip to content

Commit c54caf3

Browse files
authored
Deprecate Gson.excluder() exposing internal Excluder class (#1986)
1 parent e6fae59 commit c54caf3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

gson/src/main/java/com/google/gson/Gson.java

+22
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,40 @@ public GsonBuilder newBuilder() {
299299
return new GsonBuilder(this);
300300
}
301301

302+
/**
303+
* @deprecated This method by accident exposes an internal Gson class; it might be removed in a
304+
* future version.
305+
*/
306+
@Deprecated
302307
public Excluder excluder() {
303308
return excluder;
304309
}
305310

311+
/**
312+
* Returns the field naming strategy used by this Gson instance.
313+
*
314+
* @see GsonBuilder#setFieldNamingStrategy(FieldNamingStrategy)
315+
*/
306316
public FieldNamingStrategy fieldNamingStrategy() {
307317
return fieldNamingStrategy;
308318
}
309319

320+
/**
321+
* Returns whether this Gson instance is serializing JSON object properties with
322+
* {@code null} values, or just omits them.
323+
*
324+
* @see GsonBuilder#serializeNulls()
325+
*/
310326
public boolean serializeNulls() {
311327
return serializeNulls;
312328
}
313329

330+
/**
331+
* Returns whether this Gson instance produces JSON output which is
332+
* HTML-safe, that means all HTML characters are escaped.
333+
*
334+
* @see GsonBuilder#disableHtmlEscaping()
335+
*/
314336
public boolean htmlSafe() {
315337
return htmlSafe;
316338
}

gson/src/test/java/com/google/gson/GsonTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void testOverridesDefaultExcluder() {
5555
new ArrayList<TypeAdapterFactory>(), new ArrayList<TypeAdapterFactory>(),
5656
CUSTOM_OBJECT_TO_NUMBER_STRATEGY, CUSTOM_NUMBER_TO_NUMBER_STRATEGY);
5757

58-
assertEquals(CUSTOM_EXCLUDER, gson.excluder());
58+
assertEquals(CUSTOM_EXCLUDER, gson.excluder);
5959
assertEquals(CUSTOM_FIELD_NAMING_STRATEGY, gson.fieldNamingStrategy());
6060
assertEquals(true, gson.serializeNulls());
6161
assertEquals(false, gson.htmlSafe());

0 commit comments

Comments
 (0)