// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.streamanalytics.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.streamanalytics.fluent.models.CsvSerializationProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** Describes how data from an input is serialized or how data is serialized when written to an output in CSV format. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("Csv")
@Fluent
public final class CsvSerialization extends Serialization {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(CsvSerialization.class);

    /*
     * The properties that are associated with the CSV serialization type.
     * Required on PUT (CreateOrReplace) requests.
     */
    @JsonProperty(value = "properties")
    private CsvSerializationProperties innerProperties;

    /**
     * Get the innerProperties property: The properties that are associated with the CSV serialization type. Required on
     * PUT (CreateOrReplace) requests.
     *
     * @return the innerProperties value.
     */
    private CsvSerializationProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the fieldDelimiter property: Specifies the delimiter that will be used to separate comma-separated value
     * (CSV) records. See https://docs.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-input or
     * https://docs.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-output for a list of supported values.
     * Required on PUT (CreateOrReplace) requests.
     *
     * @return the fieldDelimiter value.
     */
    public String fieldDelimiter() {
        return this.innerProperties() == null ? null : this.innerProperties().fieldDelimiter();
    }

    /**
     * Set the fieldDelimiter property: Specifies the delimiter that will be used to separate comma-separated value
     * (CSV) records. See https://docs.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-input or
     * https://docs.microsoft.com/en-us/rest/api/streamanalytics/stream-analytics-output for a list of supported values.
     * Required on PUT (CreateOrReplace) requests.
     *
     * @param fieldDelimiter the fieldDelimiter value to set.
     * @return the CsvSerialization object itself.
     */
    public CsvSerialization withFieldDelimiter(String fieldDelimiter) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CsvSerializationProperties();
        }
        this.innerProperties().withFieldDelimiter(fieldDelimiter);
        return this;
    }

    /**
     * Get the encoding property: Specifies the encoding of the incoming data in the case of input and the encoding of
     * outgoing data in the case of output. Required on PUT (CreateOrReplace) requests.
     *
     * @return the encoding value.
     */
    public Encoding encoding() {
        return this.innerProperties() == null ? null : this.innerProperties().encoding();
    }

    /**
     * Set the encoding property: Specifies the encoding of the incoming data in the case of input and the encoding of
     * outgoing data in the case of output. Required on PUT (CreateOrReplace) requests.
     *
     * @param encoding the encoding value to set.
     * @return the CsvSerialization object itself.
     */
    public CsvSerialization withEncoding(Encoding encoding) {
        if (this.innerProperties() == null) {
            this.innerProperties = new CsvSerializationProperties();
        }
        this.innerProperties().withEncoding(encoding);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (innerProperties() != null) {
            innerProperties().validate();
        }
    }
}
