All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.billing.models.SavingsPlanUpdateValidateRequest Maven / Gradle / Ivy

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

package com.azure.resourcemanager.billing.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;

/**
 * Savings plan update validate request.
 */
@Fluent
public final class SavingsPlanUpdateValidateRequest implements JsonSerializable {
    /*
     * The benefits of a savings plan.
     */
    private List benefits;

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

    /**
     * Get the benefits property: The benefits of a savings plan.
     * 
     * @return the benefits value.
     */
    public List benefits() {
        return this.benefits;
    }

    /**
     * Set the benefits property: The benefits of a savings plan.
     * 
     * @param benefits the benefits value to set.
     * @return the SavingsPlanUpdateValidateRequest object itself.
     */
    public SavingsPlanUpdateValidateRequest withBenefits(List benefits) {
        this.benefits = benefits;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (benefits() != null) {
            benefits().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayField("benefits", this.benefits, (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of SavingsPlanUpdateValidateRequest from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SavingsPlanUpdateValidateRequest if the JsonReader was pointing to an instance of it, or
     * null if it was pointing to JSON null.
     * @throws IOException If an error occurs while reading the SavingsPlanUpdateValidateRequest.
     */
    public static SavingsPlanUpdateValidateRequest fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SavingsPlanUpdateValidateRequest deserializedSavingsPlanUpdateValidateRequest
                = new SavingsPlanUpdateValidateRequest();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("benefits".equals(fieldName)) {
                    List benefits
                        = reader.readArray(reader1 -> SavingsPlanUpdateRequestProperties.fromJson(reader1));
                    deserializedSavingsPlanUpdateValidateRequest.benefits = benefits;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSavingsPlanUpdateValidateRequest;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy