// 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.fasterxml.jackson.annotation.JsonProperty;

/** Definition of the connection fields. */
@Fluent
public final class FieldDefinition {
    /*
     * Gets or sets the isEncrypted flag of the connection field definition.
     */
    @JsonProperty(value = "isEncrypted")
    private Boolean isEncrypted;

    /*
     * Gets or sets the isOptional flag of the connection field definition.
     */
    @JsonProperty(value = "isOptional")
    private Boolean isOptional;

    /*
     * Gets or sets the type of the connection field definition.
     */
    @JsonProperty(value = "type", required = true)
    private String type;

    /**
     * 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
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property type in model FieldDefinition"));
        }
    }

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