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

com.azure.resourcemanager.frontdoor.fluent.models.RulesEngineProperties 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.frontdoor.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.frontdoor.models.FrontDoorResourceState;
import com.azure.resourcemanager.frontdoor.models.RulesEngineRule;
import com.azure.resourcemanager.frontdoor.models.RulesEngineUpdateParameters;
import java.io.IOException;
import java.util.List;

/**
 * The JSON object that contains the properties required to create a Rules Engine Configuration.
 */
@Fluent
public final class RulesEngineProperties extends RulesEngineUpdateParameters {
    /*
     * Resource status.
     */
    private FrontDoorResourceState resourceState;

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

    /**
     * Get the resourceState property: Resource status.
     * 
     * @return the resourceState value.
     */
    public FrontDoorResourceState resourceState() {
        return this.resourceState;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public RulesEngineProperties withRules(List rules) {
        super.withRules(rules);
        return this;
    }

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

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

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

                if ("rules".equals(fieldName)) {
                    List rules = reader.readArray(reader1 -> RulesEngineRule.fromJson(reader1));
                    deserializedRulesEngineProperties.withRules(rules);
                } else if ("resourceState".equals(fieldName)) {
                    deserializedRulesEngineProperties.resourceState
                        = FrontDoorResourceState.fromString(reader.getString());
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRulesEngineProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy