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

package azure.resourcemanager.methodsubscriptionid.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;

/**
 * Properties of resource group resource.
 */
@Fluent
public final class ResourceGroupResourceProperties implements JsonSerializable<ResourceGroupResourceProperties> {
    /*
     * The status of the last operation.
     */
    private ResourceProvisioningState provisioningState;

    /*
     * The resource group-scoped setting.
     */
    private String resourceGroupSetting;

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

    /**
     * Get the provisioningState property: The status of the last operation.
     * 
     * @return the provisioningState value.
     */
    public ResourceProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the resourceGroupSetting property: The resource group-scoped setting.
     * 
     * @return the resourceGroupSetting value.
     */
    public String resourceGroupSetting() {
        return this.resourceGroupSetting;
    }

    /**
     * Set the resourceGroupSetting property: The resource group-scoped setting.
     * 
     * @param resourceGroupSetting the resourceGroupSetting value to set.
     * @return the ResourceGroupResourceProperties object itself.
     */
    public ResourceGroupResourceProperties withResourceGroupSetting(String resourceGroupSetting) {
        this.resourceGroupSetting = resourceGroupSetting;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("resourceGroupSetting", this.resourceGroupSetting);
        return jsonWriter.writeEndObject();
    }

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

                if ("provisioningState".equals(fieldName)) {
                    deserializedResourceGroupResourceProperties.provisioningState
                        = ResourceProvisioningState.fromString(reader.getString());
                } else if ("resourceGroupSetting".equals(fieldName)) {
                    deserializedResourceGroupResourceProperties.resourceGroupSetting = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedResourceGroupResourceProperties;
        });
    }
}
