Deprecate Gson.excluder() exposing internal Excluder class (#1986)

This commit is contained in:
Marcono1234 2021-10-25 20:28:16 +02:00 committed by GitHub
parent e6fae590cf
commit c54caf308c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -299,18 +299,40 @@ public final class Gson {
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;
}

View File

@ -55,7 +55,7 @@ public final class GsonTest extends TestCase {
new ArrayList<TypeAdapterFactory>(), new ArrayList<TypeAdapterFactory>(),
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());