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

com.azure.resourcemanager.recoveryservicesdatareplication.models.ReplicationExtensionModelProperties 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.recoveryservicesdatareplication.models;

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

/**
 * Replication extension model properties.
 */
@Fluent
public final class ReplicationExtensionModelProperties
    implements JsonSerializable {
    /*
     * Gets or sets the provisioning state of the replication extension.
     */
    private ProvisioningState provisioningState;

    /*
     * Replication extension model custom properties.
     */
    private ReplicationExtensionModelCustomProperties customProperties;

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

    /**
     * Get the provisioningState property: Gets or sets the provisioning state of the replication extension.
     * 
     * @return the provisioningState value.
     */
    public ProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the customProperties property: Replication extension model custom properties.
     * 
     * @return the customProperties value.
     */
    public ReplicationExtensionModelCustomProperties customProperties() {
        return this.customProperties;
    }

    /**
     * Set the customProperties property: Replication extension model custom properties.
     * 
     * @param customProperties the customProperties value to set.
     * @return the ReplicationExtensionModelProperties object itself.
     */
    public ReplicationExtensionModelProperties
        withCustomProperties(ReplicationExtensionModelCustomProperties customProperties) {
        this.customProperties = customProperties;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (customProperties() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property customProperties in model ReplicationExtensionModelProperties"));
        } else {
            customProperties().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(ReplicationExtensionModelProperties.class);

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

    /**
     * Reads an instance of ReplicationExtensionModelProperties from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of ReplicationExtensionModelProperties if the JsonReader was pointing to an instance of it,
     * or null if it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the ReplicationExtensionModelProperties.
     */
    public static ReplicationExtensionModelProperties fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            ReplicationExtensionModelProperties deserializedReplicationExtensionModelProperties
                = new ReplicationExtensionModelProperties();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("customProperties".equals(fieldName)) {
                    deserializedReplicationExtensionModelProperties.customProperties
                        = ReplicationExtensionModelCustomProperties.fromJson(reader);
                } else if ("provisioningState".equals(fieldName)) {
                    deserializedReplicationExtensionModelProperties.provisioningState
                        = ProvisioningState.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedReplicationExtensionModelProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy