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

com.azure.resourcemanager.automation.models.FieldDefinition Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.

The newest version!
// 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.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;

/**
 * Definition of the connection fields.
 */
@Fluent
public final class FieldDefinition implements JsonSerializable {
    /*
     * Gets or sets the isEncrypted flag of the connection field definition.
     */
    private Boolean isEncrypted;

    /*
     * Gets or sets the isOptional flag of the connection field definition.
     */
    private Boolean isOptional;

    /*
     * Gets or sets the type of the connection field definition.
     */
    private String type;

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

    /**
     * Get the isEncrypted property: Gets or sets the isEncrypted flag of the connection field definition.
     * 
     * @return the isEncrypted value.
     */
    public Boolean isEncrypted() {
        return this.isEncrypted;
    }

    /**
     * Set the isEncrypted property: Gets or sets the isEncrypted flag of the connection field definition.
     * 
     * @param isEncrypted the isEncrypted value to set.
     * @return the FieldDefinition object itself.
     */
    public FieldDefinition withIsEncrypted(Boolean isEncrypted) {
        this.isEncrypted = isEncrypted;
        return this;
    }

    /**
     * Get the isOptional property: Gets or sets the isOptional flag of the connection field definition.
     * 
     * @return the isOptional value.
     */
    public Boolean isOptional() {
        return this.isOptional;
    }

    /**
     * Set the isOptional property: Gets or sets the isOptional flag of the connection field definition.
     * 
     * @param isOptional the isOptional value to set.
     * @return the FieldDefinition object itself.
     */
    public FieldDefinition withIsOptional(Boolean isOptional) {
        this.isOptional = isOptional;
        return this;
    }

    /**
     * Get the type property: Gets or sets the type of the connection field definition.
     * 
     * @return the type value.
     */
    public String type() {
        return this.type;
    }

    /**
     * Set the type property: Gets or sets the type of the connection field definition.
     * 
     * @param type the type value to set.
     * @return the FieldDefinition object itself.
     */
    public FieldDefinition withType(String type) {
        this.type = type;
        return this;
    }

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

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

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

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

                if ("type".equals(fieldName)) {
                    deserializedFieldDefinition.type = reader.getString();
                } else if ("isEncrypted".equals(fieldName)) {
                    deserializedFieldDefinition.isEncrypted = reader.getNullable(JsonReader::getBoolean);
                } else if ("isOptional".equals(fieldName)) {
                    deserializedFieldDefinition.isOptional = reader.getNullable(JsonReader::getBoolean);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedFieldDefinition;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy