// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.datamigration.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.Map;

/** Description about the errors happen while performing migration validation. */
@Fluent
public final class ExecutionStatistics {
    /*
     * No. of query executions
     */
    @JsonProperty(value = "executionCount", access = JsonProperty.Access.WRITE_ONLY)
    private Long executionCount;

    /*
     * CPU Time in millisecond(s) for the query execution
     */
    @JsonProperty(value = "cpuTimeMs", access = JsonProperty.Access.WRITE_ONLY)
    private Float cpuTimeMs;

    /*
     * Time taken in millisecond(s) for executing the query
     */
    @JsonProperty(value = "elapsedTimeMs", access = JsonProperty.Access.WRITE_ONLY)
    private Float elapsedTimeMs;

    /*
     * Dictionary of sql query execution wait types and the respective statistics
     */
    @JsonProperty(value = "waitStats")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, WaitStatistics> waitStats;

    /*
     * Indicates whether the query resulted in an error
     */
    @JsonProperty(value = "hasErrors", access = JsonProperty.Access.WRITE_ONLY)
    private Boolean hasErrors;

    /*
     * List of sql Errors
     */
    @JsonProperty(value = "sqlErrors", access = JsonProperty.Access.WRITE_ONLY)
    private List<String> sqlErrors;

    /** Creates an instance of ExecutionStatistics class. */
    public ExecutionStatistics() {
    }

    /**
     * Get the executionCount property: No. of query executions.
     *
     * @return the executionCount value.
     */
    public Long executionCount() {
        return this.executionCount;
    }

    /**
     * Get the cpuTimeMs property: CPU Time in millisecond(s) for the query execution.
     *
     * @return the cpuTimeMs value.
     */
    public Float cpuTimeMs() {
        return this.cpuTimeMs;
    }

    /**
     * Get the elapsedTimeMs property: Time taken in millisecond(s) for executing the query.
     *
     * @return the elapsedTimeMs value.
     */
    public Float elapsedTimeMs() {
        return this.elapsedTimeMs;
    }

    /**
     * Get the waitStats property: Dictionary of sql query execution wait types and the respective statistics.
     *
     * @return the waitStats value.
     */
    public Map<String, WaitStatistics> waitStats() {
        return this.waitStats;
    }

    /**
     * Set the waitStats property: Dictionary of sql query execution wait types and the respective statistics.
     *
     * @param waitStats the waitStats value to set.
     * @return the ExecutionStatistics object itself.
     */
    public ExecutionStatistics withWaitStats(Map<String, WaitStatistics> waitStats) {
        this.waitStats = waitStats;
        return this;
    }

    /**
     * Get the hasErrors property: Indicates whether the query resulted in an error.
     *
     * @return the hasErrors value.
     */
    public Boolean hasErrors() {
        return this.hasErrors;
    }

    /**
     * Get the sqlErrors property: List of sql Errors.
     *
     * @return the sqlErrors value.
     */
    public List<String> sqlErrors() {
        return this.sqlErrors;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (waitStats() != null) {
            waitStats()
                .values()
                .forEach(
                    e -> {
                        if (e != null) {
                            e.validate();
                        }
                    });
        }
    }
}
