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

com.azure.resourcemanager.billing.models.SavingsPlanModelListResult 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.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.billing.fluent.models.SavingsPlanModelInner;
import java.io.IOException;
import java.util.List;

/**
 * List of savings plans.
 */
@Fluent
public final class SavingsPlanModelListResult extends SavingsPlanModelList {
    /*
     * The roll out count summary of the savings plans
     */
    private SavingsPlanSummaryCount summary;

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

    /**
     * Get the summary property: The roll out count summary of the savings plans.
     * 
     * @return the summary value.
     */
    public SavingsPlanSummaryCount summary() {
        return this.summary;
    }

    /**
     * Set the summary property: The roll out count summary of the savings plans.
     * 
     * @param summary the summary value to set.
     * @return the SavingsPlanModelListResult object itself.
     */
    public SavingsPlanModelListResult withSummary(SavingsPlanSummaryCount summary) {
        this.summary = summary;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SavingsPlanModelListResult withValue(List value) {
        super.withValue(value);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public SavingsPlanModelListResult withNextLink(String nextLink) {
        super.withNextLink(nextLink);
        return this;
    }

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

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

    /**
     * Reads an instance of SavingsPlanModelListResult from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of SavingsPlanModelListResult 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 SavingsPlanModelListResult.
     */
    public static SavingsPlanModelListResult fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            SavingsPlanModelListResult deserializedSavingsPlanModelListResult = new SavingsPlanModelListResult();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("value".equals(fieldName)) {
                    List value
                        = reader.readArray(reader1 -> SavingsPlanModelInner.fromJson(reader1));
                    deserializedSavingsPlanModelListResult.withValue(value);
                } else if ("nextLink".equals(fieldName)) {
                    deserializedSavingsPlanModelListResult.withNextLink(reader.getString());
                } else if ("summary".equals(fieldName)) {
                    deserializedSavingsPlanModelListResult.summary = SavingsPlanSummaryCount.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedSavingsPlanModelListResult;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy