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

package com.azure.resourcemanager.alertsmanagement.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.List;

/** Weekly recurrence object. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "recurrenceType")
@JsonTypeName("Weekly")
@Fluent
public final class WeeklyRecurrence extends Recurrence {
    /*
     * Specifies the values for weekly recurrence pattern.
     */
    @JsonProperty(value = "daysOfWeek", required = true)
    private List<DaysOfWeek> daysOfWeek;

    /**
     * Get the daysOfWeek property: Specifies the values for weekly recurrence pattern.
     *
     * @return the daysOfWeek value.
     */
    public List<DaysOfWeek> daysOfWeek() {
        return this.daysOfWeek;
    }

    /**
     * Set the daysOfWeek property: Specifies the values for weekly recurrence pattern.
     *
     * @param daysOfWeek the daysOfWeek value to set.
     * @return the WeeklyRecurrence object itself.
     */
    public WeeklyRecurrence withDaysOfWeek(List<DaysOfWeek> daysOfWeek) {
        this.daysOfWeek = daysOfWeek;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public WeeklyRecurrence withStartTime(String startTime) {
        super.withStartTime(startTime);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public WeeklyRecurrence withEndTime(String endTime) {
        super.withEndTime(endTime);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (daysOfWeek() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property daysOfWeek in model WeeklyRecurrence"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(WeeklyRecurrence.class);
}
