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

com.azure.resourcemanager.datafactory.models.MappingDataFlow 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.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.datafactory.fluent.models.MappingDataFlowTypeProperties;
import java.io.IOException;
import java.util.List;

/**
 * Mapping data flow.
 */
@Fluent
public final class MappingDataFlow extends DataFlow {
    /*
     * Type of data flow.
     */
    private String type = "MappingDataFlow";

    /*
     * Mapping data flow type properties.
     */
    private MappingDataFlowTypeProperties innerTypeProperties;

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

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

    /**
     * Get the innerTypeProperties property: Mapping data flow type properties.
     * 
     * @return the innerTypeProperties value.
     */
    private MappingDataFlowTypeProperties innerTypeProperties() {
        return this.innerTypeProperties;
    }

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

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

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

    /**
     * Get the sources property: List of sources in data flow.
     * 
     * @return the sources value.
     */
    public List sources() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().sources();
    }

    /**
     * Set the sources property: List of sources in data flow.
     * 
     * @param sources the sources value to set.
     * @return the MappingDataFlow object itself.
     */
    public MappingDataFlow withSources(List sources) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new MappingDataFlowTypeProperties();
        }
        this.innerTypeProperties().withSources(sources);
        return this;
    }

    /**
     * Get the sinks property: List of sinks in data flow.
     * 
     * @return the sinks value.
     */
    public List sinks() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().sinks();
    }

    /**
     * Set the sinks property: List of sinks in data flow.
     * 
     * @param sinks the sinks value to set.
     * @return the MappingDataFlow object itself.
     */
    public MappingDataFlow withSinks(List sinks) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new MappingDataFlowTypeProperties();
        }
        this.innerTypeProperties().withSinks(sinks);
        return this;
    }

    /**
     * Get the transformations property: List of transformations in data flow.
     * 
     * @return the transformations value.
     */
    public List transformations() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().transformations();
    }

    /**
     * Set the transformations property: List of transformations in data flow.
     * 
     * @param transformations the transformations value to set.
     * @return the MappingDataFlow object itself.
     */
    public MappingDataFlow withTransformations(List transformations) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new MappingDataFlowTypeProperties();
        }
        this.innerTypeProperties().withTransformations(transformations);
        return this;
    }

    /**
     * Get the script property: DataFlow script.
     * 
     * @return the script value.
     */
    public String script() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().script();
    }

    /**
     * Set the script property: DataFlow script.
     * 
     * @param script the script value to set.
     * @return the MappingDataFlow object itself.
     */
    public MappingDataFlow withScript(String script) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new MappingDataFlowTypeProperties();
        }
        this.innerTypeProperties().withScript(script);
        return this;
    }

    /**
     * Get the scriptLines property: Data flow script lines.
     * 
     * @return the scriptLines value.
     */
    public List scriptLines() {
        return this.innerTypeProperties() == null ? null : this.innerTypeProperties().scriptLines();
    }

    /**
     * Set the scriptLines property: Data flow script lines.
     * 
     * @param scriptLines the scriptLines value to set.
     * @return the MappingDataFlow object itself.
     */
    public MappingDataFlow withScriptLines(List scriptLines) {
        if (this.innerTypeProperties() == null) {
            this.innerTypeProperties = new MappingDataFlowTypeProperties();
        }
        this.innerTypeProperties().withScriptLines(scriptLines);
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("description", description());
        jsonWriter.writeArrayField("annotations", annotations(), (writer, element) -> writer.writeUntyped(element));
        jsonWriter.writeJsonField("folder", folder());
        jsonWriter.writeStringField("type", this.type);
        jsonWriter.writeJsonField("typeProperties", this.innerTypeProperties);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of MappingDataFlow from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of MappingDataFlow if the JsonReader was pointing to an instance of it, or null if it was
     * pointing to JSON null.
     * @throws IOException If an error occurs while reading the MappingDataFlow.
     */
    public static MappingDataFlow fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            MappingDataFlow deserializedMappingDataFlow = new MappingDataFlow();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("description".equals(fieldName)) {
                    deserializedMappingDataFlow.withDescription(reader.getString());
                } else if ("annotations".equals(fieldName)) {
                    List annotations = reader.readArray(reader1 -> reader1.readUntyped());
                    deserializedMappingDataFlow.withAnnotations(annotations);
                } else if ("folder".equals(fieldName)) {
                    deserializedMappingDataFlow.withFolder(DataFlowFolder.fromJson(reader));
                } else if ("type".equals(fieldName)) {
                    deserializedMappingDataFlow.type = reader.getString();
                } else if ("typeProperties".equals(fieldName)) {
                    deserializedMappingDataFlow.innerTypeProperties = MappingDataFlowTypeProperties.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedMappingDataFlow;
        });
    }
}