All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.clientlib.JSON Maven / Gradle / Ivy

/*
Copyright 2020 Twitter, Inc.
SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
https://openapi-generator.tech
Do not edit the class manually.
*/


package com.twitter.clientlib;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.bind.util.ISO8601Utils;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonElement;
import io.gsonfire.GsonFireBuilder;
import io.gsonfire.TypeSelector;

import okio.ByteString;

import java.io.IOException;
import java.io.StringReader;
import java.lang.reflect.Type;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.HashMap;

/*
 * A JSON utility class
 *
 * NOTE: in the future, this class may be converted to static, which may break
 *       backward-compatibility
 */
public class JSON {
    private static Gson gson;
    private static boolean isLenientOnJson = false;
    private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
    private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
    private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter();
    private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
    private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();

    @SuppressWarnings("unchecked")
    public static GsonBuilder createGson() {
        GsonFireBuilder fireBuilder = new GsonFireBuilder()
                .registerTypeSelector(com.twitter.clientlib.model.AnimatedGif.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("animated_gif", com.twitter.clientlib.model.AnimatedGif.class);
                        classByDiscriminatorValue.put("photo", com.twitter.clientlib.model.Photo.class);
                        classByDiscriminatorValue.put("video", com.twitter.clientlib.model.Video.class);
                        classByDiscriminatorValue.put("AnimatedGif", com.twitter.clientlib.model.AnimatedGif.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.ClientDisconnectedProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("ClientDisconnectedProblem", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.ClientForbiddenProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("ClientForbiddenProblem", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.ConflictProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("ConflictProblem", com.twitter.clientlib.model.ConflictProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.ConnectionExceptionProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("ConnectionExceptionProblem", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.DisallowedResourceProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("DisallowedResourceProblem", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.DuplicateRuleProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("DuplicateRuleProblem", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.FieldUnauthorizedProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("FieldUnauthorizedProblem", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.GenericProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("GenericProblem", com.twitter.clientlib.model.GenericProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.InvalidRequestProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("InvalidRequestProblem", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.InvalidRuleProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("InvalidRuleProblem", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.Media.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("AnimatedGif", com.twitter.clientlib.model.AnimatedGif.class);
                        classByDiscriminatorValue.put("Photo", com.twitter.clientlib.model.Photo.class);
                        classByDiscriminatorValue.put("Video", com.twitter.clientlib.model.Video.class);
                        classByDiscriminatorValue.put("animated_gif", com.twitter.clientlib.model.AnimatedGif.class);
                        classByDiscriminatorValue.put("photo", com.twitter.clientlib.model.Photo.class);
                        classByDiscriminatorValue.put("video", com.twitter.clientlib.model.Video.class);
                        classByDiscriminatorValue.put("Media", com.twitter.clientlib.model.Media.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.NonCompliantRulesProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("NonCompliantRulesProblem", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.OperationalDisconnectProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("OperationalDisconnectProblem", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.Photo.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("animated_gif", com.twitter.clientlib.model.AnimatedGif.class);
                        classByDiscriminatorValue.put("photo", com.twitter.clientlib.model.Photo.class);
                        classByDiscriminatorValue.put("video", com.twitter.clientlib.model.Video.class);
                        classByDiscriminatorValue.put("Photo", com.twitter.clientlib.model.Photo.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.Problem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("ClientDisconnectedProblem", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("ClientForbiddenProblem", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("ConflictProblem", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("ConnectionExceptionProblem", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("DisallowedResourceProblem", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("DuplicateRuleProblem", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("FieldUnauthorizedProblem", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("GenericProblem", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("InvalidRequestProblem", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("InvalidRuleProblem", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("NonCompliantRulesProblem", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("OperationalDisconnectProblem", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("ResourceNotFoundProblem", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("ResourceUnauthorizedProblem", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("ResourceUnavailableProblem", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("RulesCapProblem", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("UnsupportedAuthenticationProblem", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("UsageCapExceededProblem", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("Problem", com.twitter.clientlib.model.Problem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.ResourceNotFoundProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("ResourceNotFoundProblem", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.ResourceUnauthorizedProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("ResourceUnauthorizedProblem", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.ResourceUnavailableProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("ResourceUnavailableProblem", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.RulesCapProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("RulesCapProblem", com.twitter.clientlib.model.RulesCapProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("UnsupportedAuthenticationProblem", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.UsageCapExceededProblem.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("about:blank", com.twitter.clientlib.model.GenericProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-disconnected", com.twitter.clientlib.model.ClientDisconnectedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/client-forbidden", com.twitter.clientlib.model.ClientForbiddenProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/conflict", com.twitter.clientlib.model.ConflictProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/disallowed-resource", com.twitter.clientlib.model.DisallowedResourceProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/duplicate-rules", com.twitter.clientlib.model.DuplicateRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-request", com.twitter.clientlib.model.InvalidRequestProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/invalid-rules", com.twitter.clientlib.model.InvalidRuleProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/noncompliant-rules", com.twitter.clientlib.model.NonCompliantRulesProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-field", com.twitter.clientlib.model.FieldUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/not-authorized-for-resource", com.twitter.clientlib.model.ResourceUnauthorizedProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/operational-disconnect", com.twitter.clientlib.model.OperationalDisconnectProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-not-found", com.twitter.clientlib.model.ResourceNotFoundProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/resource-unavailable", com.twitter.clientlib.model.ResourceUnavailableProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/rule-cap", com.twitter.clientlib.model.RulesCapProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/streaming-connection", com.twitter.clientlib.model.ConnectionExceptionProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/unsupported-authentication", com.twitter.clientlib.model.UnsupportedAuthenticationProblem.class);
                        classByDiscriminatorValue.put("https://api.twitter.com/2/problems/usage-capped", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        classByDiscriminatorValue.put("UsageCapExceededProblem", com.twitter.clientlib.model.UsageCapExceededProblem.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
                .registerTypeSelector(com.twitter.clientlib.model.Video.class, new TypeSelector() {
                    @Override
                    public Class getClassForElement(JsonElement readElement) {
                        Map classByDiscriminatorValue = new HashMap();
                        classByDiscriminatorValue.put("animated_gif", com.twitter.clientlib.model.AnimatedGif.class);
                        classByDiscriminatorValue.put("photo", com.twitter.clientlib.model.Photo.class);
                        classByDiscriminatorValue.put("video", com.twitter.clientlib.model.Video.class);
                        classByDiscriminatorValue.put("Video", com.twitter.clientlib.model.Video.class);
                        return getClassByDiscriminator(classByDiscriminatorValue,
                                getDiscriminatorValue(readElement, "type"));
                    }
          })
        ;
        GsonBuilder builder = fireBuilder.createGsonBuilder();
        return builder;
    }

    private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) {
        JsonElement element = readElement.getAsJsonObject().get(discriminatorField);
        if (null == element) {
            throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">");
        }
        return element.getAsString();
    }

    /**
     * Returns the Java class that implements the OpenAPI schema for the specified discriminator value.
     *
     * @param classByDiscriminatorValue The map of discriminator values to Java classes.
     * @param discriminatorValue The value of the OpenAPI discriminator in the input data.
     * @return The Java class that implements the OpenAPI schema
     */
    private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) {
        Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue);
        if (null == clazz) {
            throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">");
        }
        return clazz;
    }

    {
        GsonBuilder gsonBuilder = createGson();
        gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter);
        gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter);
        gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter);
        gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter);
        gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter);
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.AddOrDeleteRulesRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.AddOrDeleteRulesResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.AddRulesRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.AnimatedGif.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.AnimatedGifAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.BlockUserMutationResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.BlockUserMutationResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.BlockUserRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.BookmarkAddRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.BookmarkMutationResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.BookmarkMutationResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CashtagEntity.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CashtagFields.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ClientDisconnectedProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ClientForbiddenProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ClientForbiddenProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ComplianceJob.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ConflictProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ConnectionExceptionProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ConnectionExceptionProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ContextAnnotation.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ContextAnnotationDomainFields.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ContextAnnotationEntityFields.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateComplianceJobRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.CreateComplianceJobResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DeleteRulesRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DeleteRulesRequestDelete.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DisallowedResourceProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DisallowedResourceProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DuplicateRuleProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.DuplicateRuleProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.EntityIndicesInclusiveExclusive.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.EntityIndicesInclusiveInclusive.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Error.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Expansions.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.FieldUnauthorizedProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.FieldUnauthorizedProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.FilteredStreamingTweetResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.FilteredStreamingTweetResponseMatchingRules.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.FullTextEntities.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.FullTextEntitiesAnnotations.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.FullTextEntitiesAnnotationsAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.GenericProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Geo.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ComplianceJobsIdResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ComplianceJobsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ComplianceJobsResponseMeta.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdFollowersResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdFollowersResponseMeta.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdMembersResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2ListsIdTweetsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2SpacesByCreatorIdsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2SpacesIdBuyersResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2SpacesIdResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2SpacesIdTweetsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2SpacesResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2SpacesSearchResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsCountsAllResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsCountsAllResponseMeta.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsCountsRecentResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsIdLikingUsersResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsIdQuoteTweetsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsIdQuoteTweetsResponseMeta.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsIdResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsIdRetweetedByResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsSampleStreamResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsSearchAllResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsSearchAllResponseMeta.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsSearchRecentResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2TweetsSearchStreamResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersByResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersByUsernameUsernameResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdBlockingResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdBookmarksResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdFollowedListsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdFollowersResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdFollowingResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdLikedTweetsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdListMembershipsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdMentionsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdMentionsResponseMeta.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdMutingResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdOwnedListsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdPinnedListsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdTimelinesReverseChronologicalResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersIdTweetsResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersMeResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Get2UsersResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.HashtagEntity.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.HashtagFields.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.InvalidRequestProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.InvalidRequestProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.InvalidRequestProblemAllOfErrors.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.InvalidRuleProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListAddUserRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListCreateRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListCreateResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListCreateResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListDeleteResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListDeleteResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListFollowedRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListFollowedResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListFollowedResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListMutateResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListMutateResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListPinnedRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListPinnedResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListPinnedResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListUnpinResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListUpdateRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListUpdateResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ListUpdateResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.MentionEntity.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.MentionFields.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ModelList.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.MuteUserMutationResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.MuteUserMutationResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.MuteUserRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.NonCompliantRulesProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.OperationalDisconnectProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.OperationalDisconnectProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Photo.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.PhotoAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Place.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Point.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Poll.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.PollOption.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ProblemErrors.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ProblemOrError.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ReportUsersRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ReportUsersResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ReportUsersResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceNotFoundProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceNotFoundProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceUnauthorizedProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceUnauthorizedProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceUnavailableProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.ResourceUnavailableProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Rule.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.RuleNoId.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.RulesCapProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.RulesLookupResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.RulesRequestSummary.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.RulesRequestSummaryOneOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.RulesRequestSummaryOneOf1.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.RulesResponseMetadata.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.SearchCount.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Space.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.SpaceTopics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.StreamingTweetResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Topic.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Tweet.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetAttachments.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetCreateRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetCreateRequestGeo.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetCreateRequestMedia.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetCreateRequestPoll.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetCreateRequestReply.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetCreateResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetCreateResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetDeleteResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetDeleteResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetGeo.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetHideRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetHideResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetHideResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetNonPublicMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetOrganicMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetPromotedMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetPublicMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetReferencedTweets.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.TweetWithheld.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UnsupportedAuthenticationProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UrlEntity.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UrlFields.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UrlImage.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsageCapExceededProblem.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsageCapExceededProblemAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.User.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UserEntities.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UserEntitiesUrl.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UserPublicMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UserWithheld.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersFollowingCreateRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersFollowingCreateResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersFollowingCreateResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersFollowingDeleteResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersLikesCreateRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersLikesCreateResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersLikesCreateResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersLikesDeleteResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersRetweetsCreateRequest.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersRetweetsCreateResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersRetweetsCreateResponseData.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.UsersRetweetsDeleteResponse.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Variant.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.Video.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.VideoAllOf.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.VideoAllOfNonPublicMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.VideoAllOfOrganicMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.VideoAllOfPromotedMetrics.CustomTypeAdapterFactory());
        gsonBuilder.registerTypeAdapterFactory(new com.twitter.clientlib.model.VideoAllOfPublicMetrics.CustomTypeAdapterFactory());
        gson = gsonBuilder.create();
    }

    /**
     * Get Gson.
     *
     * @return Gson
     */
    public static Gson getGson() {
        return gson;
    }

    /**
     * Set Gson.
     *
     * @param gson Gson
     */
    public static void setGson(Gson gson) {
        JSON.gson = gson;
    }

    public static void setLenientOnJson(boolean lenientOnJson) {
        isLenientOnJson = lenientOnJson;
    }

    /**
     * Serialize the given Java object into JSON string.
     *
     * @param obj Object
     * @return String representation of the JSON
     */
    public static String serialize(Object obj) {
        return gson.toJson(obj);
    }

    /**
     * Deserialize the given JSON string to Java object.
     *
     * @param         Type
     * @param body       The JSON string
     * @param returnType The type to deserialize into
     * @return The deserialized Java object
     */
    @SuppressWarnings("unchecked")
    public static  T deserialize(String body, Type returnType) {
        try {
            if (isLenientOnJson) {
                JsonReader jsonReader = new JsonReader(new StringReader(body));
                // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
                jsonReader.setLenient(true);
                return gson.fromJson(jsonReader, returnType);
            } else {
                return gson.fromJson(body, returnType);
            }
        } catch (JsonParseException e) {
            // Fallback processing when failed to parse JSON form response body:
            // return the response body string directly for the String return type;
            if (returnType.equals(String.class)) {
                return (T) body;
            } else {
                throw (e);
            }
        }
    }

    /**
     * Gson TypeAdapter for Byte Array type
     */
    public static class ByteArrayAdapter extends TypeAdapter {

        @Override
        public void write(JsonWriter out, byte[] value) throws IOException {
            if (value == null) {
                out.nullValue();
            } else {
                out.value(ByteString.of(value).base64());
            }
        }

        @Override
        public byte[] read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String bytesAsBase64 = in.nextString();
                    ByteString byteString = ByteString.decodeBase64(bytesAsBase64);
                    return byteString.toByteArray();
            }
        }
    }

    /**
     * Gson TypeAdapter for JSR310 OffsetDateTime type
     */
    public static class OffsetDateTimeTypeAdapter extends TypeAdapter {

        private DateTimeFormatter formatter;

        public OffsetDateTimeTypeAdapter() {
            this(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
        }

        public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) {
            this.formatter = formatter;
        }

        public void setFormat(DateTimeFormatter dateFormat) {
            this.formatter = dateFormat;
        }

        @Override
        public void write(JsonWriter out, OffsetDateTime date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                out.value(formatter.format(date));
            }
        }

        @Override
        public OffsetDateTime read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String date = in.nextString();
                    if (date.endsWith("+0000")) {
                        date = date.substring(0, date.length()-5) + "Z";
                    }
                    return OffsetDateTime.parse(date, formatter);
            }
        }
    }

    /**
     * Gson TypeAdapter for JSR310 LocalDate type
     */
    public static class LocalDateTypeAdapter extends TypeAdapter {

        private DateTimeFormatter formatter;

        public LocalDateTypeAdapter() {
            this(DateTimeFormatter.ISO_LOCAL_DATE);
        }

        public LocalDateTypeAdapter(DateTimeFormatter formatter) {
            this.formatter = formatter;
        }

        public void setFormat(DateTimeFormatter dateFormat) {
            this.formatter = dateFormat;
        }

        @Override
        public void write(JsonWriter out, LocalDate date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                out.value(formatter.format(date));
            }
        }

        @Override
        public LocalDate read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String date = in.nextString();
                    return LocalDate.parse(date, formatter);
            }
        }
    }

    public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) {
        offsetDateTimeTypeAdapter.setFormat(dateFormat);
    }

    public static void setLocalDateFormat(DateTimeFormatter dateFormat) {
        localDateTypeAdapter.setFormat(dateFormat);
    }

    /**
     * Gson TypeAdapter for java.sql.Date type
     * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used
     * (more efficient than SimpleDateFormat).
     */
    public static class SqlDateTypeAdapter extends TypeAdapter {

        private DateFormat dateFormat;

        public SqlDateTypeAdapter() {}

        public SqlDateTypeAdapter(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        public void setFormat(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        @Override
        public void write(JsonWriter out, java.sql.Date date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                String value;
                if (dateFormat != null) {
                    value = dateFormat.format(date);
                } else {
                    value = date.toString();
                }
                out.value(value);
            }
        }

        @Override
        public java.sql.Date read(JsonReader in) throws IOException {
            switch (in.peek()) {
                case NULL:
                    in.nextNull();
                    return null;
                default:
                    String date = in.nextString();
                    try {
                        if (dateFormat != null) {
                            return new java.sql.Date(dateFormat.parse(date).getTime());
                        }
                        return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
                    } catch (ParseException e) {
                        throw new JsonParseException(e);
                    }
            }
        }
    }

    /**
     * Gson TypeAdapter for java.util.Date type
     * If the dateFormat is null, ISO8601Utils will be used.
     */
    public static class DateTypeAdapter extends TypeAdapter {

        private DateFormat dateFormat;

        public DateTypeAdapter() {}

        public DateTypeAdapter(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        public void setFormat(DateFormat dateFormat) {
            this.dateFormat = dateFormat;
        }

        @Override
        public void write(JsonWriter out, Date date) throws IOException {
            if (date == null) {
                out.nullValue();
            } else {
                String value;
                if (dateFormat != null) {
                    value = dateFormat.format(date);
                } else {
                    value = ISO8601Utils.format(date, true);
                }
                out.value(value);
            }
        }

        @Override
        public Date read(JsonReader in) throws IOException {
            try {
                switch (in.peek()) {
                    case NULL:
                        in.nextNull();
                        return null;
                    default:
                        String date = in.nextString();
                        try {
                            if (dateFormat != null) {
                                return dateFormat.parse(date);
                            }
                            return ISO8601Utils.parse(date, new ParsePosition(0));
                        } catch (ParseException e) {
                            throw new JsonParseException(e);
                        }
                }
            } catch (IllegalArgumentException e) {
                throw new JsonParseException(e);
            }
        }
    }

    public static void setDateFormat(DateFormat dateFormat) {
        dateTypeAdapter.setFormat(dateFormat);
    }

    public static void setSqlDateFormat(DateFormat dateFormat) {
        sqlDateTypeAdapter.setFormat(dateFormat);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy