// 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.JsonSerializationProperties;
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 JSON format.
 */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonTypeName("Json")
@Fluent
public final class JsonSerialization extends Serialization {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(JsonSerialization.class);

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

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

    /**
     * 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 JsonSerialization object itself.
     */
    public JsonSerialization withEncoding(Encoding encoding) {
        if (this.innerProperties() == null) {
            this.innerProperties = new JsonSerializationProperties();
        }
        this.innerProperties().withEncoding(encoding);
        return this;
    }

    /**
     * Get the format property: This property only applies to JSON serialization of outputs only. It is not applicable
     * to inputs. This property specifies the format of the JSON the output will be written in. The currently supported
     * values are 'lineSeparated' indicating the output will be formatted by having each JSON object separated by a new
     * line and 'array' indicating the output will be formatted as an array of JSON objects. Default value is
     * 'lineSeparated' if left null.
     *
     * @return the format value.
     */
    public JsonOutputSerializationFormat format() {
        return this.innerProperties() == null ? null : this.innerProperties().format();
    }

    /**
     * Set the format property: This property only applies to JSON serialization of outputs only. It is not applicable
     * to inputs. This property specifies the format of the JSON the output will be written in. The currently supported
     * values are 'lineSeparated' indicating the output will be formatted by having each JSON object separated by a new
     * line and 'array' indicating the output will be formatted as an array of JSON objects. Default value is
     * 'lineSeparated' if left null.
     *
     * @param format the format value to set.
     * @return the JsonSerialization object itself.
     */
    public JsonSerialization withFormat(JsonOutputSerializationFormat format) {
        if (this.innerProperties() == null) {
            this.innerProperties = new JsonSerializationProperties();
        }
        this.innerProperties().withFormat(format);
        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();
        }
    }
}
