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

package tsptest.subclass.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 PropertyChangedToRequiredParent model.
 */
@Fluent
public class PropertyChangedToRequiredParent implements JsonSerializable<PropertyChangedToRequiredParent> {
    /*
     * The propertyChangedToRequired property.
     */
    @Generated
    private String propertyChangedToRequired;

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

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

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

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

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

                if ("propertyChangedToRequired".equals(fieldName)) {
                    deserializedPropertyChangedToRequiredParent.propertyChangedToRequired = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPropertyChangedToRequiredParent;
        });
    }
}
