content: /*
   * Decompiled with CFR 0.153-SNAPSHOT (d6f6758-dirty).
   */
  package com.google.gson;
  
  import com.google.gson.DefaultDateTypeAdapter;
  import com.google.gson.ExclusionStrategy;
  import com.google.gson.FieldNamingPolicy;
  import com.google.gson.FieldNamingStrategy;
  import com.google.gson.Gson;
  import com.google.gson.InstanceCreator;
  import com.google.gson.JsonDeserializer;
  import com.google.gson.JsonSerializer;
  import com.google.gson.LongSerializationPolicy;
  import com.google.gson.TypeAdapter;
  import com.google.gson.TypeAdapterFactory;
  import com.google.gson.internal.$Gson$Preconditions;
  import com.google.gson.internal.Excluder;
  import com.google.gson.internal.bind.TreeTypeAdapter;
  import com.google.gson.internal.bind.TypeAdapters;
  import com.google.gson.reflect.TypeToken;
  import java.lang.reflect.Type;
  import java.sql.Date;
  import java.sql.Timestamp;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  public final class GsonBuilder {
      private Excluder excluder = Excluder.DEFAULT;
      private LongSerializationPolicy longSerializationPolicy = LongSerializationPolicy.DEFAULT;
      private FieldNamingStrategy fieldNamingPolicy = FieldNamingPolicy.IDENTITY;
      private final Map<Type, InstanceCreator<?>> instanceCreators = new HashMap();
      private final List<TypeAdapterFactory> factories = new ArrayList<TypeAdapterFactory>();
      private final List<TypeAdapterFactory> hierarchyFactories = new ArrayList<TypeAdapterFactory>();
      private boolean serializeNulls = false;
      private String datePattern;
      private int dateStyle = 2;
      private int timeStyle = 2;
      private boolean complexMapKeySerialization = false;
      private boolean serializeSpecialFloatingPointValues = false;
      private boolean escapeHtmlChars = true;
      private boolean prettyPrinting = false;
      private boolean generateNonExecutableJson = false;
      private boolean lenient = false;
  
      public GsonBuilder() {
      }
  
      GsonBuilder(Gson gson) {
          this.excluder = gson.excluder;
          this.fieldNamingPolicy = gson.fieldNamingStrategy;
          this.instanceCreators.putAll(gson.instanceCreators);
          this.serializeNulls = gson.serializeNulls;
          this.complexMapKeySerialization = gson.complexMapKeySerialization;
          this.generateNonExecutableJson = gson.generateNonExecutableJson;
          this.escapeHtmlChars = gson.htmlSafe;
          this.prettyPrinting = gson.prettyPrinting;
          this.lenient = gson.lenient;
          this.serializeSpecialFloatingPointValues = gson.serializeSpecialFloatingPointValues;
          this.longSerializationPolicy = gson.longSerializationPolicy;
          this.datePattern = gson.datePattern;
          this.dateStyle = gson.dateStyle;
          this.timeStyle = gson.timeStyle;
          this.factories.addAll(gson.builderFactories);
          this.hierarchyFactories.addAll(gson.builderHierarchyFactories);
      }
  
      public GsonBuilder setVersion(double ignoreVersionsAfter) {
          this.excluder = this.excluder.withVersion(ignoreVersionsAfter);
          return this;
      }
  
      public GsonBuilder excludeFieldsWithModifiers(int ... modifiers) {
          this.excluder = this.excluder.withModifiers(modifiers);
          return this;
      }
  
      public GsonBuilder generateNonExecutableJson() {
          this.generateNonExecutableJson = true;
          return this;
      }
  
      public GsonBuilder excludeFieldsWithoutExposeAnnotation() {
          this.excluder = this.excluder.excludeFieldsWithoutExposeAnnotation();
          return this;
      }
  
      public GsonBuilder serializeNulls() {
          this.serializeNulls = true;
          return this;
      }
  
      public GsonBuilder enableComplexMapKeySerialization() {
          this.complexMapKeySerialization = true;
          return this;
      }
  
      public GsonBuilder disableInnerClassSerialization() {
          this.excluder = this.excluder.disableInnerClassSerialization();
          return this;
      }
  
      public GsonBuilder setLongSerializationPolicy(LongSerializationPolicy serializationPolicy) {
          this.longSerializationPolicy = serializationPolicy;
          return this;
      }
  
      public GsonBuilder setFieldNamingPolicy(FieldNamingPolicy namingConvention) {
          this.fieldNamingPolicy = namingConvention;
          return this;
      }
  
      public GsonBuilder setFieldNamingStrategy(FieldNamingStrategy fieldNamingStrategy) {
          this.fieldNamingPolicy = fieldNamingStrategy;
          return this;
      }
  
      public GsonBuilder setExclusionStrategies(ExclusionStrategy ... strategies) {
          for (ExclusionStrategy strategy : strategies) {
              this.excluder = this.excluder.withExclusionStrategy(strategy, true, true);
          }
          return this;
      }
  
      public GsonBuilder addSerializationExclusionStrategy(ExclusionStrategy strategy) {
          this.excluder = this.excluder.withExclusionStrategy(strategy, true, false);
          return this;
      }
  
      public GsonBuilder addDeserializationExclusionStrategy(ExclusionStrategy strategy) {
          this.excluder = this.excluder.withExclusionStrategy(strategy, false, true);
          return this;
      }
  
      public GsonBuilder setPrettyPrinting() {
          this.prettyPrinting = true;
          return this;
      }
  
      public GsonBuilder setLenient() {
          this.lenient = true;
          return this;
      }
  
      public GsonBuilder disableHtmlEscaping() {
          this.escapeHtmlChars = false;
          return this;
      }
  
      public GsonBuilder setDateFormat(String pattern) {
          this.datePattern = pattern;
          return this;
      }
  
      public GsonBuilder setDateFormat(int style) {
          this.dateStyle = style;
          this.datePattern = null;
          return this;
      }
  
      public GsonBuilder setDateFormat(int dateStyle, int timeStyle) {
          this.dateStyle = dateStyle;
          this.timeStyle = timeStyle;
          this.datePattern = null;
          return this;
      }
  
      public GsonBuilder registerTypeAdapter(Type type, Object typeAdapter) {
          $Gson$Preconditions.checkArgument(typeAdapter instanceof JsonSerializer || typeAdapter instanceof JsonDeserializer || typeAdapter instanceof InstanceCreator || typeAdapter instanceof TypeAdapter);
          if (typeAdapter instanceof InstanceCreator) {
              this.instanceCreators.put(type, (InstanceCreator)typeAdapter);
          }
          if (typeAdapter instanceof JsonSerializer || typeAdapter instanceof JsonDeserializer) {
              TypeToken<?> typeToken = TypeToken.get(type);
              this.factories.add(TreeTypeAdapter.newFactoryWithMatchRawType(typeToken, typeAdapter));
          }
          if (typeAdapter instanceof TypeAdapter) {
              this.factories.add(TypeAdapters.newFactory(TypeToken.get(type), (TypeAdapter)typeAdapter));
          }
          return this;
      }
  
      public GsonBuilder registerTypeAdapterFactory(TypeAdapterFactory factory2) {
          this.factories.add(factory2);
          return this;
      }
  
      public GsonBuilder registerTypeHierarchyAdapter(Class<?> baseType, Object typeAdapter) {
          $Gson$Preconditions.checkArgument(typeAdapter instanceof JsonSerializer || typeAdapter instanceof JsonDeserializer || typeAdapter instanceof TypeAdapter);
          if (typeAdapter instanceof JsonDeserializer || typeAdapter instanceof JsonSerializer) {
              this.hierarchyFactories.add(TreeTypeAdapter.newTypeHierarchyFactory(baseType, typeAdapter));
          }
          if (typeAdapter instanceof TypeAdapter) {
              this.factories.add(TypeAdapters.newTypeHierarchyFactory(baseType, (TypeAdapter)typeAdapter));
          }
          return this;
      }
  
      public GsonBuilder serializeSpecialFloatingPointValues() {
          this.serializeSpecialFloatingPointValues = true;
          return this;
      }
  
      public Gson create() {
          ArrayList<TypeAdapterFactory> factories = new ArrayList<TypeAdapterFactory>(this.factories.size() + this.hierarchyFactories.size() + 3);
          factories.addAll(this.factories);
          Collections.reverse(factories);
          ArrayList<TypeAdapterFactory> hierarchyFactories = new ArrayList<TypeAdapterFactory>(this.hierarchyFactories);
          Collections.reverse(hierarchyFactories);
          factories.addAll(hierarchyFactories);
          this.addTypeAdaptersForDate(this.datePattern, this.dateStyle, this.timeStyle, factories);
          return new Gson(this.excluder, this.fieldNamingPolicy, this.instanceCreators, this.serializeNulls, this.complexMapKeySerialization, this.generateNonExecutableJson, this.escapeHtmlChars, this.prettyPrinting, this.lenient, this.serializeSpecialFloatingPointValues, this.longSerializationPolicy, this.datePattern, this.dateStyle, this.timeStyle, this.factories, this.hierarchyFactories, factories);
      }
  
      private void addTypeAdaptersForDate(String datePattern, int dateStyle, int timeStyle, List<TypeAdapterFactory> factories) {
          DefaultDateTypeAdapter javaSqlDateTypeAdapter;
          DefaultDateTypeAdapter timestampTypeAdapter;
          DefaultDateTypeAdapter dateTypeAdapter;
          if (datePattern != null && !"".equals(datePattern.trim())) {
              dateTypeAdapter = new DefaultDateTypeAdapter(java.util.Date.class, datePattern);
              timestampTypeAdapter = new DefaultDateTypeAdapter(Timestamp.class, datePattern);
              javaSqlDateTypeAdapter = new DefaultDateTypeAdapter(Date.class, datePattern);
          } else if (dateStyle != 2 && timeStyle != 2) {
              dateTypeAdapter = new DefaultDateTypeAdapter(java.util.Date.class, dateStyle, timeStyle);
              timestampTypeAdapter = new DefaultDateTypeAdapter(Timestamp.class, dateStyle, timeStyle);
              javaSqlDateTypeAdapter = new DefaultDateTypeAdapter(Date.class, dateStyle, timeStyle);
          } else {
              return;
          }
          factories.add(TypeAdapters.newFactory(java.util.Date.class, dateTypeAdapter));
          factories.add(TypeAdapters.newFactory(Timestamp.class, timestampTypeAdapter));
          factories.add(TypeAdapters.newFactory(Date.class, javaSqlDateTypeAdapter));
      }
  }
  
  