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

import java.math.*;

import javax.annotation.Generated;

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

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

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

    public SlotMigration unmarshall(JsonUnmarshallerContext context) throws Exception {
        SlotMigration slotMigration = new SlotMigration();

        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("ProgressPercentage", targetDepth)) {
                    context.nextToken();
                    slotMigration.setProgressPercentage(context.getUnmarshaller(Double.class).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 slotMigration;
    }

    private static SlotMigrationJsonUnmarshaller instance;

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