1616
1717package com .google .gson ;
1818
19- import java .lang .reflect .Type ;
20- import java .text .DateFormat ;
21- import java .util .ArrayList ;
22- import java .util .Collections ;
23- import java .util .Date ;
24- import java .util .HashMap ;
25- import java .util .LinkedList ;
26- import java .util .List ;
27- import java .util .Map ;
28-
29- import com .google .gson .internal .$Gson$Preconditions ;
30- import com .google .gson .internal .Excluder ;
31- import com .google .gson .internal .bind .DefaultDateTypeAdapter ;
32- import com .google .gson .internal .bind .TreeTypeAdapter ;
33- import com .google .gson .internal .bind .TypeAdapters ;
34- import com .google .gson .internal .sql .SqlTypesSupport ;
35- import com .google .gson .reflect .TypeToken ;
36- import com .google .gson .stream .JsonReader ;
37- import com .google .gson .stream .JsonWriter ;
38-
3919import static com .google .gson .Gson .DEFAULT_COMPLEX_MAP_KEYS ;
4020import static com .google .gson .Gson .DEFAULT_DATE_PATTERN ;
4121import static com .google .gson .Gson .DEFAULT_ESCAPE_HTML ;
4828import static com .google .gson .Gson .DEFAULT_SPECIALIZE_FLOAT_VALUES ;
4929import static com .google .gson .Gson .DEFAULT_USE_JDK_UNSAFE ;
5030
31+ import com .google .gson .internal .$Gson$Preconditions ;
32+ import com .google .gson .internal .Excluder ;
33+ import com .google .gson .internal .bind .DefaultDateTypeAdapter ;
34+ import com .google .gson .internal .bind .TreeTypeAdapter ;
35+ import com .google .gson .internal .bind .TypeAdapters ;
36+ import com .google .gson .internal .sql .SqlTypesSupport ;
37+ import com .google .gson .reflect .TypeToken ;
38+ import com .google .gson .stream .JsonReader ;
39+ import com .google .gson .stream .JsonWriter ;
40+ import java .lang .reflect .Type ;
41+ import java .text .DateFormat ;
42+ import java .util .ArrayList ;
43+ import java .util .Collections ;
44+ import java .util .Date ;
45+ import java .util .HashMap ;
46+ import java .util .LinkedList ;
47+ import java .util .List ;
48+ import java .util .Map ;
49+ import java .util .Objects ;
50+
5151/**
5252 * <p>Use this builder to construct a {@link Gson} instance when you need to set configuration
5353 * options other than the default. For {@link Gson} with default configuration, it is simpler to
@@ -166,7 +166,7 @@ public GsonBuilder setVersion(double ignoreVersionsAfter) {
166166 * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
167167 */
168168 public GsonBuilder excludeFieldsWithModifiers (int ... modifiers ) {
169- $Gson$Preconditions . checkNotNull (modifiers );
169+ Objects . requireNonNull (modifiers );
170170 excluder = excluder .withModifiers (modifiers );
171171 return this ;
172172 }
@@ -310,8 +310,7 @@ public GsonBuilder disableInnerClassSerialization() {
310310 * @since 1.3
311311 */
312312 public GsonBuilder setLongSerializationPolicy (LongSerializationPolicy serializationPolicy ) {
313- $Gson$Preconditions .checkNotNull (serializationPolicy );
314- this .longSerializationPolicy = serializationPolicy ;
313+ this .longSerializationPolicy = Objects .requireNonNull (serializationPolicy );
315314 return this ;
316315 }
317316
@@ -334,8 +333,7 @@ public GsonBuilder setFieldNamingPolicy(FieldNamingPolicy namingConvention) {
334333 * @since 1.3
335334 */
336335 public GsonBuilder setFieldNamingStrategy (FieldNamingStrategy fieldNamingStrategy ) {
337- $Gson$Preconditions .checkNotNull (fieldNamingStrategy );
338- this .fieldNamingPolicy = fieldNamingStrategy ;
336+ this .fieldNamingPolicy = Objects .requireNonNull (fieldNamingStrategy );
339337 return this ;
340338 }
341339
@@ -347,8 +345,7 @@ public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrateg
347345 * @see ToNumberPolicy#DOUBLE The default object-to-number strategy
348346 */
349347 public GsonBuilder setObjectToNumberStrategy (ToNumberStrategy objectToNumberStrategy ) {
350- $Gson$Preconditions .checkNotNull (objectToNumberStrategy );
351- this .objectToNumberStrategy = objectToNumberStrategy ;
348+ this .objectToNumberStrategy = Objects .requireNonNull (objectToNumberStrategy );
352349 return this ;
353350 }
354351
@@ -360,8 +357,7 @@ public GsonBuilder setObjectToNumberStrategy(ToNumberStrategy objectToNumberStra
360357 * @see ToNumberPolicy#LAZILY_PARSED_NUMBER The default number-to-number strategy
361358 */
362359 public GsonBuilder setNumberToNumberStrategy (ToNumberStrategy numberToNumberStrategy ) {
363- $Gson$Preconditions .checkNotNull (numberToNumberStrategy );
364- this .numberToNumberStrategy = numberToNumberStrategy ;
360+ this .numberToNumberStrategy = Objects .requireNonNull (numberToNumberStrategy );
365361 return this ;
366362 }
367363
@@ -378,7 +374,7 @@ public GsonBuilder setNumberToNumberStrategy(ToNumberStrategy numberToNumberStra
378374 * @since 1.4
379375 */
380376 public GsonBuilder setExclusionStrategies (ExclusionStrategy ... strategies ) {
381- $Gson$Preconditions . checkNotNull (strategies );
377+ Objects . requireNonNull (strategies );
382378 for (ExclusionStrategy strategy : strategies ) {
383379 excluder = excluder .withExclusionStrategy (strategy , true , true );
384380 }
@@ -398,7 +394,7 @@ public GsonBuilder setExclusionStrategies(ExclusionStrategy... strategies) {
398394 * @since 1.7
399395 */
400396 public GsonBuilder addSerializationExclusionStrategy (ExclusionStrategy strategy ) {
401- $Gson$Preconditions . checkNotNull (strategy );
397+ Objects . requireNonNull (strategy );
402398 excluder = excluder .withExclusionStrategy (strategy , true , false );
403399 return this ;
404400 }
@@ -416,7 +412,7 @@ public GsonBuilder addSerializationExclusionStrategy(ExclusionStrategy strategy)
416412 * @since 1.7
417413 */
418414 public GsonBuilder addDeserializationExclusionStrategy (ExclusionStrategy strategy ) {
419- $Gson$Preconditions . checkNotNull (strategy );
415+ Objects . requireNonNull (strategy );
420416 excluder = excluder .withExclusionStrategy (strategy , false , true );
421417 return this ;
422418 }
@@ -547,7 +543,7 @@ public GsonBuilder setDateFormat(int dateStyle, int timeStyle) {
547543 */
548544 @ SuppressWarnings ({"unchecked" , "rawtypes" })
549545 public GsonBuilder registerTypeAdapter (Type type , Object typeAdapter ) {
550- $Gson$Preconditions . checkNotNull (type );
546+ Objects . requireNonNull (type );
551547 $Gson$Preconditions .checkArgument (typeAdapter instanceof JsonSerializer <?>
552548 || typeAdapter instanceof JsonDeserializer <?>
553549 || typeAdapter instanceof InstanceCreator <?>
@@ -574,7 +570,7 @@ public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
574570 * @since 2.1
575571 */
576572 public GsonBuilder registerTypeAdapterFactory (TypeAdapterFactory factory ) {
577- $Gson$Preconditions . checkNotNull (factory );
573+ Objects . requireNonNull (factory );
578574 factories .add (factory );
579575 return this ;
580576 }
@@ -595,7 +591,7 @@ public GsonBuilder registerTypeAdapterFactory(TypeAdapterFactory factory) {
595591 */
596592 @ SuppressWarnings ({"unchecked" , "rawtypes" })
597593 public GsonBuilder registerTypeHierarchyAdapter (Class <?> baseType , Object typeAdapter ) {
598- $Gson$Preconditions . checkNotNull (baseType );
594+ Objects . requireNonNull (baseType );
599595 $Gson$Preconditions .checkArgument (typeAdapter instanceof JsonSerializer <?>
600596 || typeAdapter instanceof JsonDeserializer <?>
601597 || typeAdapter instanceof TypeAdapter <?>);
@@ -669,7 +665,7 @@ public GsonBuilder disableJdkUnsafe() {
669665 * @return a reference to this {@code GsonBuilder} object to fulfill the "Builder" pattern
670666 */
671667 public GsonBuilder addReflectionAccessFilter (ReflectionAccessFilter filter ) {
672- $Gson$Preconditions . checkNotNull (filter );
668+ Objects . requireNonNull (filter );
673669 reflectionFilters .addFirst (filter );
674670 return this ;
675671 }
0 commit comments