/*
 * Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file 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.
 */
package com.amazonaws.services.quicksight.model.transform;

import java.math.*;

import javax.annotation.Generated;

import com.amazonaws.services.quicksight.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;

import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;

/**
 * DataSourceParameters JSON Unmarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class DataSourceParametersJsonUnmarshaller implements Unmarshaller<DataSourceParameters, JsonUnmarshallerContext> {

    public DataSourceParameters unmarshall(JsonUnmarshallerContext context) throws Exception {
        DataSourceParameters dataSourceParameters = new DataSourceParameters();

        int originalDepth = context.getCurrentDepth();
        String currentParentElement = context.getCurrentParentElement();
        int targetDepth = originalDepth + 1;

        JsonToken token = context.getCurrentToken();
        if (token == null)
            token = context.nextToken();
        if (token == VALUE_NULL) {
            return null;
        }

        while (true) {
            if (token == null)
                break;

            if (token == FIELD_NAME || token == START_OBJECT) {
                if (context.testExpression("AmazonElasticsearchParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setAmazonElasticsearchParameters(AmazonElasticsearchParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("AthenaParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setAthenaParameters(AthenaParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("AuroraParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setAuroraParameters(AuroraParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("AuroraPostgreSqlParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setAuroraPostgreSqlParameters(AuroraPostgreSqlParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("AwsIotAnalyticsParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setAwsIotAnalyticsParameters(AwsIotAnalyticsParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("JiraParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setJiraParameters(JiraParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("MariaDbParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setMariaDbParameters(MariaDbParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("MySqlParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setMySqlParameters(MySqlParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("OracleParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setOracleParameters(OracleParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("PostgreSqlParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setPostgreSqlParameters(PostgreSqlParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("PrestoParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setPrestoParameters(PrestoParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("RdsParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setRdsParameters(RdsParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("RedshiftParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setRedshiftParameters(RedshiftParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("S3Parameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setS3Parameters(S3ParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("ServiceNowParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setServiceNowParameters(ServiceNowParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("SnowflakeParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setSnowflakeParameters(SnowflakeParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("SparkParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setSparkParameters(SparkParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("SqlServerParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setSqlServerParameters(SqlServerParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("TeradataParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setTeradataParameters(TeradataParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("TwitterParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setTwitterParameters(TwitterParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("AmazonOpenSearchParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setAmazonOpenSearchParameters(AmazonOpenSearchParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("ExasolParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setExasolParameters(ExasolParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
                if (context.testExpression("DatabricksParameters", targetDepth)) {
                    context.nextToken();
                    dataSourceParameters.setDatabricksParameters(DatabricksParametersJsonUnmarshaller.getInstance().unmarshall(context));
                }
            } else if (token == END_ARRAY || token == END_OBJECT) {
                if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
                    if (context.getCurrentDepth() <= originalDepth)
                        break;
                }
            }
            token = context.nextToken();
        }

        return dataSourceParameters;
    }

    private static DataSourceParametersJsonUnmarshaller instance;

    public static DataSourceParametersJsonUnmarshaller getInstance() {
        if (instance == null)
            instance = new DataSourceParametersJsonUnmarshaller();
        return instance;
    }
}
