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

package com.azure.resourcemanager.managedapplications.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;

/** Plan for the managed application. */
@Fluent
public final class Plan {
    /*
     * The plan name.
     */
    @JsonProperty(value = "name", required = true)
    private String name;

    /*
     * The publisher ID.
     */
    @JsonProperty(value = "publisher", required = true)
    private String publisher;

    /*
     * The product code.
     */
    @JsonProperty(value = "product", required = true)
    private String product;

    /*
     * The promotion code.
     */
    @JsonProperty(value = "promotionCode")
    private String promotionCode;

    /*
     * The plan's version.
     */
    @JsonProperty(value = "version", required = true)
    private String version;

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

    /**
     * Get the name property: The plan name.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The plan name.
     *
     * @param name the name value to set.
     * @return the Plan object itself.
     */
    public Plan withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the publisher property: The publisher ID.
     *
     * @return the publisher value.
     */
    public String publisher() {
        return this.publisher;
    }

    /**
     * Set the publisher property: The publisher ID.
     *
     * @param publisher the publisher value to set.
     * @return the Plan object itself.
     */
    public Plan withPublisher(String publisher) {
        this.publisher = publisher;
        return this;
    }

    /**
     * Get the product property: The product code.
     *
     * @return the product value.
     */
    public String product() {
        return this.product;
    }

    /**
     * Set the product property: The product code.
     *
     * @param product the product value to set.
     * @return the Plan object itself.
     */
    public Plan withProduct(String product) {
        this.product = product;
        return this;
    }

    /**
     * Get the promotionCode property: The promotion code.
     *
     * @return the promotionCode value.
     */
    public String promotionCode() {
        return this.promotionCode;
    }

    /**
     * Set the promotionCode property: The promotion code.
     *
     * @param promotionCode the promotionCode value to set.
     * @return the Plan object itself.
     */
    public Plan withPromotionCode(String promotionCode) {
        this.promotionCode = promotionCode;
        return this;
    }

    /**
     * Get the version property: The plan's version.
     *
     * @return the version value.
     */
    public String version() {
        return this.version;
    }

    /**
     * Set the version property: The plan's version.
     *
     * @param version the version value to set.
     * @return the Plan object itself.
     */
    public Plan withVersion(String version) {
        this.version = version;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (name() == null) {
            throw LOGGER
                .logExceptionAsError(new IllegalArgumentException("Missing required property name in model Plan"));
        }
        if (publisher() == null) {
            throw LOGGER
                .logExceptionAsError(new IllegalArgumentException("Missing required property publisher in model Plan"));
        }
        if (product() == null) {
            throw LOGGER
                .logExceptionAsError(new IllegalArgumentException("Missing required property product in model Plan"));
        }
        if (version() == null) {
            throw LOGGER
                .logExceptionAsError(new IllegalArgumentException("Missing required property version in model Plan"));
        }
    }

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