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

package com.azure.resourcemanager.consumption.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** The start and end date for a budget. */
@Fluent
public final class BudgetTimePeriod {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(BudgetTimePeriod.class);

    /*
     * The start date for the budget.
     */
    @JsonProperty(value = "startDate", required = true)
    private OffsetDateTime startDate;

    /*
     * The end date for the budget. If not provided, we default this to 10
     * years from the start date.
     */
    @JsonProperty(value = "endDate")
    private OffsetDateTime endDate;

    /**
     * Get the startDate property: The start date for the budget.
     *
     * @return the startDate value.
     */
    public OffsetDateTime startDate() {
        return this.startDate;
    }

    /**
     * Set the startDate property: The start date for the budget.
     *
     * @param startDate the startDate value to set.
     * @return the BudgetTimePeriod object itself.
     */
    public BudgetTimePeriod withStartDate(OffsetDateTime startDate) {
        this.startDate = startDate;
        return this;
    }

    /**
     * Get the endDate property: The end date for the budget. If not provided, we default this to 10 years from the
     * start date.
     *
     * @return the endDate value.
     */
    public OffsetDateTime endDate() {
        return this.endDate;
    }

    /**
     * Set the endDate property: The end date for the budget. If not provided, we default this to 10 years from the
     * start date.
     *
     * @param endDate the endDate value to set.
     * @return the BudgetTimePeriod object itself.
     */
    public BudgetTimePeriod withEndDate(OffsetDateTime endDate) {
        this.endDate = endDate;
        return this;
    }

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