
package com.amazonaws.services.lexmodelsv2.model.transform;

import java.math.*;

import javax.annotation.Generated;

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

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

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

    public ConversationLogSettings unmarshall(JsonUnmarshallerContext context) throws Exception {
        ConversationLogSettings conversationLogSettings = new ConversationLogSettings();

        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("textLogSettings", targetDepth)) {
                    context.nextToken();
                    conversationLogSettings.setTextLogSettings(new ListUnmarshaller<TextLogSetting>(TextLogSettingJsonUnmarshaller.getInstance())

                    .unmarshall(context));
                }
                if (context.testExpression("audioLogSettings", targetDepth)) {
                    context.nextToken();
                    conversationLogSettings.setAudioLogSettings(new ListUnmarshaller<AudioLogSetting>(AudioLogSettingJsonUnmarshaller.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 conversationLogSettings;
    }

    private static ConversationLogSettingsJsonUnmarshaller instance;

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