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

package com.azure.resourcemanager.machinelearning.models;

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

/** Optimization objective. */
@Fluent
public final class Objective {
    /*
     * [Required] Defines supported metric goals for hyperparameter tuning
     */
    @JsonProperty(value = "goal", required = true)
    private Goal goal;

    /*
     * [Required] Name of the metric to optimize.
     */
    @JsonProperty(value = "primaryMetric", required = true)
    private String primaryMetric;

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

    /**
     * Get the goal property: [Required] Defines supported metric goals for hyperparameter tuning.
     *
     * @return the goal value.
     */
    public Goal goal() {
        return this.goal;
    }

    /**
     * Set the goal property: [Required] Defines supported metric goals for hyperparameter tuning.
     *
     * @param goal the goal value to set.
     * @return the Objective object itself.
     */
    public Objective withGoal(Goal goal) {
        this.goal = goal;
        return this;
    }

    /**
     * Get the primaryMetric property: [Required] Name of the metric to optimize.
     *
     * @return the primaryMetric value.
     */
    public String primaryMetric() {
        return this.primaryMetric;
    }

    /**
     * Set the primaryMetric property: [Required] Name of the metric to optimize.
     *
     * @param primaryMetric the primaryMetric value to set.
     * @return the Objective object itself.
     */
    public Objective withPrimaryMetric(String primaryMetric) {
        this.primaryMetric = primaryMetric;
        return this;
    }

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

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