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

com.azure.resourcemanager.billing.models.ReservationExtendedStatusInfo 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;

/**
 * Extended status information for the reservation.
 */
@Fluent
public final class ReservationExtendedStatusInfo implements JsonSerializable {
    /*
     * The status of the reservation.
     */
    private ReservationStatusCode statusCode;

    /*
     * The message giving detailed information about the status code.
     */
    private String message;

    /*
     * Properties for extended status information
     */
    private ExtendedStatusDefinitionProperties properties;

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

    /**
     * Get the statusCode property: The status of the reservation.
     * 
     * @return the statusCode value.
     */
    public ReservationStatusCode statusCode() {
        return this.statusCode;
    }

    /**
     * Set the statusCode property: The status of the reservation.
     * 
     * @param statusCode the statusCode value to set.
     * @return the ReservationExtendedStatusInfo object itself.
     */
    public ReservationExtendedStatusInfo withStatusCode(ReservationStatusCode statusCode) {
        this.statusCode = statusCode;
        return this;
    }

    /**
     * Get the message property: The message giving detailed information about the status code.
     * 
     * @return the message value.
     */
    public String message() {
        return this.message;
    }

    /**
     * Set the message property: The message giving detailed information about the status code.
     * 
     * @param message the message value to set.
     * @return the ReservationExtendedStatusInfo object itself.
     */
    public ReservationExtendedStatusInfo withMessage(String message) {
        this.message = message;
        return this;
    }

    /**
     * Get the properties property: Properties for extended status information.
     * 
     * @return the properties value.
     */
    public ExtendedStatusDefinitionProperties properties() {
        return this.properties;
    }

    /**
     * Set the properties property: Properties for extended status information.
     * 
     * @param properties the properties value to set.
     * @return the ReservationExtendedStatusInfo object itself.
     */
    public ReservationExtendedStatusInfo withProperties(ExtendedStatusDefinitionProperties properties) {
        this.properties = properties;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("statusCode", this.statusCode == null ? null : this.statusCode.toString());
        jsonWriter.writeStringField("message", this.message);
        jsonWriter.writeJsonField("properties", this.properties);
        return jsonWriter.writeEndObject();
    }

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

                if ("statusCode".equals(fieldName)) {
                    deserializedReservationExtendedStatusInfo.statusCode
                        = ReservationStatusCode.fromString(reader.getString());
                } else if ("message".equals(fieldName)) {
                    deserializedReservationExtendedStatusInfo.message = reader.getString();
                } else if ("properties".equals(fieldName)) {
                    deserializedReservationExtendedStatusInfo.properties
                        = ExtendedStatusDefinitionProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedReservationExtendedStatusInfo;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy