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

package com.azure.resourcemanager.servicefabric.models;

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

/**
 * Defines a delta health policy used to evaluate the health of an application or one of its child entities when
 * upgrading the cluster.
 */
@Fluent
public final class ApplicationDeltaHealthPolicy {
    /*
     * The delta health policy used by default to evaluate the health of a service type when upgrading the cluster.
     */
    @JsonProperty(value = "defaultServiceTypeDeltaHealthPolicy")
    private ServiceTypeDeltaHealthPolicy defaultServiceTypeDeltaHealthPolicy;

    /*
     * The map with service type delta health policy per service type name. The map is empty by default.
     */
    @JsonProperty(value = "serviceTypeDeltaHealthPolicies")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, ServiceTypeDeltaHealthPolicy> serviceTypeDeltaHealthPolicies;

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

    /**
     * Get the defaultServiceTypeDeltaHealthPolicy property: The delta health policy used by default to evaluate the
     * health of a service type when upgrading the cluster.
     *
     * @return the defaultServiceTypeDeltaHealthPolicy value.
     */
    public ServiceTypeDeltaHealthPolicy defaultServiceTypeDeltaHealthPolicy() {
        return this.defaultServiceTypeDeltaHealthPolicy;
    }

    /**
     * Set the defaultServiceTypeDeltaHealthPolicy property: The delta health policy used by default to evaluate the
     * health of a service type when upgrading the cluster.
     *
     * @param defaultServiceTypeDeltaHealthPolicy the defaultServiceTypeDeltaHealthPolicy value to set.
     * @return the ApplicationDeltaHealthPolicy object itself.
     */
    public ApplicationDeltaHealthPolicy withDefaultServiceTypeDeltaHealthPolicy(
        ServiceTypeDeltaHealthPolicy defaultServiceTypeDeltaHealthPolicy) {
        this.defaultServiceTypeDeltaHealthPolicy = defaultServiceTypeDeltaHealthPolicy;
        return this;
    }

    /**
     * Get the serviceTypeDeltaHealthPolicies property: The map with service type delta health policy per service type
     * name. The map is empty by default.
     *
     * @return the serviceTypeDeltaHealthPolicies value.
     */
    public Map<String, ServiceTypeDeltaHealthPolicy> serviceTypeDeltaHealthPolicies() {
        return this.serviceTypeDeltaHealthPolicies;
    }

    /**
     * Set the serviceTypeDeltaHealthPolicies property: The map with service type delta health policy per service type
     * name. The map is empty by default.
     *
     * @param serviceTypeDeltaHealthPolicies the serviceTypeDeltaHealthPolicies value to set.
     * @return the ApplicationDeltaHealthPolicy object itself.
     */
    public ApplicationDeltaHealthPolicy withServiceTypeDeltaHealthPolicies(
        Map<String, ServiceTypeDeltaHealthPolicy> serviceTypeDeltaHealthPolicies) {
        this.serviceTypeDeltaHealthPolicies = serviceTypeDeltaHealthPolicies;
        return this;
    }

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