// 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;

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

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

    /**
     * Set the daysOfMonth property: Specifies the values for monthly recurrence pattern.
     *
     * @param daysOfMonth the daysOfMonth value to set.
     * @return the MonthlyRecurrence object itself.
     */
    public MonthlyRecurrence withDaysOfMonth(List<Integer> daysOfMonth) {
        this.daysOfMonth = daysOfMonth;
        return this;
    }

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

    /** {@inheritDoc} */
    @Override
    public MonthlyRecurrence 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 (daysOfMonth() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property daysOfMonth in model MonthlyRecurrence"));
        }
    }

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