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

package com.azure.resourcemanager.deploymentmanager.models;

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

/** Defines a service. */
@Fluent
public final class Service extends ServiceProperties {
    /*
     * Name of the service.
     */
    @JsonProperty(value = "name")
    private String name;

    /*
     * The detailed information about the units that make up the service.
     */
    @JsonProperty(value = "serviceUnits")
    private List<ServiceUnit> serviceUnits;

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

    /**
     * Get the name property: Name of the service.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Name of the service.
     *
     * @param name the name value to set.
     * @return the Service object itself.
     */
    public Service withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the serviceUnits property: The detailed information about the units that make up the service.
     *
     * @return the serviceUnits value.
     */
    public List<ServiceUnit> serviceUnits() {
        return this.serviceUnits;
    }

    /**
     * Set the serviceUnits property: The detailed information about the units that make up the service.
     *
     * @param serviceUnits the serviceUnits value to set.
     * @return the Service object itself.
     */
    public Service withServiceUnits(List<ServiceUnit> serviceUnits) {
        this.serviceUnits = serviceUnits;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public Service withTargetLocation(String targetLocation) {
        super.withTargetLocation(targetLocation);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public Service withTargetSubscriptionId(String targetSubscriptionId) {
        super.withTargetSubscriptionId(targetSubscriptionId);
        return this;
    }

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