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

com.azure.resourcemanager.automation.models.TargetProperties 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.automation.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;
import java.util.List;

/**
 * Group specific to the update configuration.
 */
@Fluent
public final class TargetProperties implements JsonSerializable {
    /*
     * List of Azure queries in the software update configuration.
     */
    private List azureQueries;

    /*
     * List of non Azure queries in the software update configuration.
     */
    private List nonAzureQueries;

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

    /**
     * Get the azureQueries property: List of Azure queries in the software update configuration.
     * 
     * @return the azureQueries value.
     */
    public List azureQueries() {
        return this.azureQueries;
    }

    /**
     * Set the azureQueries property: List of Azure queries in the software update configuration.
     * 
     * @param azureQueries the azureQueries value to set.
     * @return the TargetProperties object itself.
     */
    public TargetProperties withAzureQueries(List azureQueries) {
        this.azureQueries = azureQueries;
        return this;
    }

    /**
     * Get the nonAzureQueries property: List of non Azure queries in the software update configuration.
     * 
     * @return the nonAzureQueries value.
     */
    public List nonAzureQueries() {
        return this.nonAzureQueries;
    }

    /**
     * Set the nonAzureQueries property: List of non Azure queries in the software update configuration.
     * 
     * @param nonAzureQueries the nonAzureQueries value to set.
     * @return the TargetProperties object itself.
     */
    public TargetProperties withNonAzureQueries(List nonAzureQueries) {
        this.nonAzureQueries = nonAzureQueries;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (azureQueries() != null) {
            azureQueries().forEach(e -> e.validate());
        }
        if (nonAzureQueries() != null) {
            nonAzureQueries().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayField("azureQueries", this.azureQueries, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("nonAzureQueries", this.nonAzureQueries,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("azureQueries".equals(fieldName)) {
                    List azureQueries
                        = reader.readArray(reader1 -> AzureQueryProperties.fromJson(reader1));
                    deserializedTargetProperties.azureQueries = azureQueries;
                } else if ("nonAzureQueries".equals(fieldName)) {
                    List nonAzureQueries
                        = reader.readArray(reader1 -> NonAzureQueryProperties.fromJson(reader1));
                    deserializedTargetProperties.nonAzureQueries = nonAzureQueries;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedTargetProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy