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

com.azure.resourcemanager.datafactory.models.DelimitedTextDataset 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.datafactory.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.datafactory.fluent.models.DelimitedTextDatasetTypeProperties;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Delimited text dataset.
 */
@Fluent
public final class DelimitedTextDataset extends Dataset {
    /*
     * Type of dataset.
     */
    private String type = "DelimitedText";

    /*
     * Delimited text dataset properties.
     */
    private DelimitedTextDatasetTypeProperties innerTypeProperties;

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

    /**
     * Get the type property: Type of dataset.
     * 
     * @return the type value.
     */
    @Override
    public String type() {
        return this.type;
    }

    /**
     * Get the innerTypeProperties property: Delimited text dataset properties.
     * 
     * @return the innerTypeProperties value.
     */
    private DelimitedTextDatasetTypeProperties innerTypeProperties() {
        return this.innerTypeProperties;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DelimitedTextDataset withDescription(String description) {
        super.withDescription(description);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DelimitedTextDataset withStructure(Object structure) {
        super.withStructure(structure);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DelimitedTextDataset withSchema(Object schema) {
        super.withSchema(schema);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DelimitedTextDataset withLinkedServiceName(LinkedServiceReference linkedServiceName) {
        super.withLinkedServiceName(linkedServiceName);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DelimitedTextDataset withParameters(Map parameters) {
        super.withParameters(parameters);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DelimitedTextDataset withAnnotations(List annotations) {
        super.withAnnotations(annotations);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public DelimitedTextDataset withFolder(DatasetFolder folder) {
        super.withFolder(folder);
        return this;
    }

    /**
     * Get the location property: The location of the delimited text storage.
     * 
     * @return the location value.
     */
    public DatasetLocation location() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().location();
    }

    /**
     * Set the location property: The location of the delimited text storage.
     * 
     * @param location the location value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withLocation(DatasetLocation location) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withLocation(location);
        return this;
    }

    /**
     * Get the columnDelimiter property: The column delimiter. Type: string (or Expression with resultType string).
     * 
     * @return the columnDelimiter value.
     */
    public Object columnDelimiter() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().columnDelimiter();
    }

    /**
     * Set the columnDelimiter property: The column delimiter. Type: string (or Expression with resultType string).
     * 
     * @param columnDelimiter the columnDelimiter value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withColumnDelimiter(Object columnDelimiter) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withColumnDelimiter(columnDelimiter);
        return this;
    }

    /**
     * Get the rowDelimiter property: The row delimiter. Type: string (or Expression with resultType string).
     * 
     * @return the rowDelimiter value.
     */
    public Object rowDelimiter() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().rowDelimiter();
    }

    /**
     * Set the rowDelimiter property: The row delimiter. Type: string (or Expression with resultType string).
     * 
     * @param rowDelimiter the rowDelimiter value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withRowDelimiter(Object rowDelimiter) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withRowDelimiter(rowDelimiter);
        return this;
    }

    /**
     * Get the encodingName property: The code page name of the preferred encoding. If miss, the default value is UTF-8,
     * unless BOM denotes another Unicode encoding. Refer to the name column of the table in the following link to set
     * supported values: https://msdn.microsoft.com/library/system.text.encoding.aspx. Type: string (or Expression with
     * resultType string).
     * 
     * @return the encodingName value.
     */
    public Object encodingName() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().encodingName();
    }

    /**
     * Set the encodingName property: The code page name of the preferred encoding. If miss, the default value is UTF-8,
     * unless BOM denotes another Unicode encoding. Refer to the name column of the table in the following link to set
     * supported values: https://msdn.microsoft.com/library/system.text.encoding.aspx. Type: string (or Expression with
     * resultType string).
     * 
     * @param encodingName the encodingName value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withEncodingName(Object encodingName) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withEncodingName(encodingName);
        return this;
    }

    /**
     * Get the compressionCodec property: The data compressionCodec. Type: string (or Expression with resultType
     * string).
     * 
     * @return the compressionCodec value.
     */
    public Object compressionCodec() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().compressionCodec();
    }

    /**
     * Set the compressionCodec property: The data compressionCodec. Type: string (or Expression with resultType
     * string).
     * 
     * @param compressionCodec the compressionCodec value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withCompressionCodec(Object compressionCodec) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withCompressionCodec(compressionCodec);
        return this;
    }

    /**
     * Get the compressionLevel property: The data compression method used for DelimitedText.
     * 
     * @return the compressionLevel value.
     */
    public Object compressionLevel() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().compressionLevel();
    }

    /**
     * Set the compressionLevel property: The data compression method used for DelimitedText.
     * 
     * @param compressionLevel the compressionLevel value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withCompressionLevel(Object compressionLevel) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withCompressionLevel(compressionLevel);
        return this;
    }

    /**
     * Get the quoteChar property: The quote character. Type: string (or Expression with resultType string).
     * 
     * @return the quoteChar value.
     */
    public Object quoteChar() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().quoteChar();
    }

    /**
     * Set the quoteChar property: The quote character. Type: string (or Expression with resultType string).
     * 
     * @param quoteChar the quoteChar value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withQuoteChar(Object quoteChar) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withQuoteChar(quoteChar);
        return this;
    }

    /**
     * Get the escapeChar property: The escape character. Type: string (or Expression with resultType string).
     * 
     * @return the escapeChar value.
     */
    public Object escapeChar() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().escapeChar();
    }

    /**
     * Set the escapeChar property: The escape character. Type: string (or Expression with resultType string).
     * 
     * @param escapeChar the escapeChar value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withEscapeChar(Object escapeChar) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withEscapeChar(escapeChar);
        return this;
    }

    /**
     * Get the firstRowAsHeader property: When used as input, treat the first row of data as headers. When used as
     * output,write the headers into the output as the first row of data. The default value is false. Type: boolean (or
     * Expression with resultType boolean).
     * 
     * @return the firstRowAsHeader value.
     */
    public Object firstRowAsHeader() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().firstRowAsHeader();
    }

    /**
     * Set the firstRowAsHeader property: When used as input, treat the first row of data as headers. When used as
     * output,write the headers into the output as the first row of data. The default value is false. Type: boolean (or
     * Expression with resultType boolean).
     * 
     * @param firstRowAsHeader the firstRowAsHeader value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withFirstRowAsHeader(Object firstRowAsHeader) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withFirstRowAsHeader(firstRowAsHeader);
        return this;
    }

    /**
     * Get the nullValue property: The null value string. Type: string (or Expression with resultType string).
     * 
     * @return the nullValue value.
     */
    public Object nullValue() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().nullValue();
    }

    /**
     * Set the nullValue property: The null value string. Type: string (or Expression with resultType string).
     * 
     * @param nullValue the nullValue value to set.
     * @return the DelimitedTextDataset object itself.
     */
    public DelimitedTextDataset withNullValue(Object nullValue) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new DelimitedTextDatasetTypeProperties();
        }
        this.innerTypeProperties().withNullValue(nullValue);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (innerTypeProperties() != null) {
            innerTypeProperties().validate();
        }
        if (linkedServiceName() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property linkedServiceName in model DelimitedTextDataset"));
        } else {
            linkedServiceName().validate();
        }
        if (parameters() != null) {
            parameters().values().forEach(e -> {
                if (e != null) {
                    e.validate();
                }
            });
        }
        if (folder() != null) {
            folder().validate();
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("linkedServiceName", linkedServiceName());
        jsonWriter.writeStringField("description", description());
        jsonWriter.writeUntypedField("structure", structure());
        jsonWriter.writeUntypedField("schema", schema());
        jsonWriter.writeMapField("parameters", parameters(), (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("annotations", annotations(), (writer, element) -> writer.writeUntyped(element));
        jsonWriter.writeJsonField("folder", folder());
        jsonWriter.writeStringField("type", this.type);
        jsonWriter.writeJsonField("typeProperties", this.innerTypeProperties);
        if (additionalProperties() != null) {
            for (Map.Entry additionalProperty : additionalProperties().entrySet()) {
                jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
            }
        }
        return jsonWriter.writeEndObject();
    }

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

                if ("linkedServiceName".equals(fieldName)) {
                    deserializedDelimitedTextDataset.withLinkedServiceName(LinkedServiceReference.fromJson(reader));
                } else if ("description".equals(fieldName)) {
                    deserializedDelimitedTextDataset.withDescription(reader.getString());
                } else if ("structure".equals(fieldName)) {
                    deserializedDelimitedTextDataset.withStructure(reader.readUntyped());
                } else if ("schema".equals(fieldName)) {
                    deserializedDelimitedTextDataset.withSchema(reader.readUntyped());
                } else if ("parameters".equals(fieldName)) {
                    Map parameters
                        = reader.readMap(reader1 -> ParameterSpecification.fromJson(reader1));
                    deserializedDelimitedTextDataset.withParameters(parameters);
                } else if ("annotations".equals(fieldName)) {
                    List annotations = reader.readArray(reader1 -> reader1.readUntyped());
                    deserializedDelimitedTextDataset.withAnnotations(annotations);
                } else if ("folder".equals(fieldName)) {
                    deserializedDelimitedTextDataset.withFolder(DatasetFolder.fromJson(reader));
                } else if ("type".equals(fieldName)) {
                    deserializedDelimitedTextDataset.type = reader.getString();
                } else if ("typeProperties".equals(fieldName)) {
                    deserializedDelimitedTextDataset.innerTypeProperties
                        = DelimitedTextDatasetTypeProperties.fromJson(reader);
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

                    additionalProperties.put(fieldName, reader.readUntyped());
                }
            }
            deserializedDelimitedTextDataset.withAdditionalProperties(additionalProperties);

            return deserializedDelimitedTextDataset;
        });
    }
}