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

package parameters.bodyroot.models;

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

/**
 * The BodyRootModel model.
 */
@Fluent
public final class BodyRootModel implements JsonSerializable<BodyRootModel> {
    /*
     * The category property.
     */
    @Generated
    private String category;

    /*
     * The linkType property.
     */
    @Generated
    private String linkType;

    /*
     * The wasSuccessful property.
     */
    @Generated
    private Boolean wasSuccessful;

    /**
     * Creates an instance of BodyRootModel class.
     */
    @Generated
    public BodyRootModel() {
    }

    /**
     * Get the category property: The category property.
     * 
     * @return the category value.
     */
    @Generated
    public String getCategory() {
        return this.category;
    }

    /**
     * Set the category property: The category property.
     * 
     * @param category the category value to set.
     * @return the BodyRootModel object itself.
     */
    @Generated
    public BodyRootModel setCategory(String category) {
        this.category = category;
        return this;
    }

    /**
     * Get the linkType property: The linkType property.
     * 
     * @return the linkType value.
     */
    @Generated
    public String getLinkType() {
        return this.linkType;
    }

    /**
     * Set the linkType property: The linkType property.
     * 
     * @param linkType the linkType value to set.
     * @return the BodyRootModel object itself.
     */
    @Generated
    public BodyRootModel setLinkType(String linkType) {
        this.linkType = linkType;
        return this;
    }

    /**
     * Get the wasSuccessful property: The wasSuccessful property.
     * 
     * @return the wasSuccessful value.
     */
    @Generated
    public Boolean isWasSuccessful() {
        return this.wasSuccessful;
    }

    /**
     * Set the wasSuccessful property: The wasSuccessful property.
     * 
     * @param wasSuccessful the wasSuccessful value to set.
     * @return the BodyRootModel object itself.
     */
    @Generated
    public BodyRootModel setWasSuccessful(Boolean wasSuccessful) {
        this.wasSuccessful = wasSuccessful;
        return this;
    }

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

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

                if ("category".equals(fieldName)) {
                    deserializedBodyRootModel.category = reader.getString();
                } else if ("linkType".equals(fieldName)) {
                    deserializedBodyRootModel.linkType = reader.getString();
                } else if ("wasSuccessful".equals(fieldName)) {
                    deserializedBodyRootModel.wasSuccessful = reader.getNullable(JsonReader::getBoolean);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedBodyRootModel;
        });
    }
}
