
com.azure.resourcemanager.datafactory.models.ScriptActivityScriptBlock 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.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;
/**
* Script block of scripts.
*/
@Fluent
public final class ScriptActivityScriptBlock implements JsonSerializable {
/*
* The query text. Type: string (or Expression with resultType string).
*/
private Object text;
/*
* The type of the query. Please refer to the ScriptType for valid options. Type: string (or Expression with
* resultType string).
*/
private Object type;
/*
* Array of script parameters. Type: array.
*/
private List parameters;
/**
* Creates an instance of ScriptActivityScriptBlock class.
*/
public ScriptActivityScriptBlock() {
}
/**
* Get the text property: The query text. Type: string (or Expression with resultType string).
*
* @return the text value.
*/
public Object text() {
return this.text;
}
/**
* Set the text property: The query text. Type: string (or Expression with resultType string).
*
* @param text the text value to set.
* @return the ScriptActivityScriptBlock object itself.
*/
public ScriptActivityScriptBlock withText(Object text) {
this.text = text;
return this;
}
/**
* Get the type property: The type of the query. Please refer to the ScriptType for valid options. Type: string (or
* Expression with resultType string).
*
* @return the type value.
*/
public Object type() {
return this.type;
}
/**
* Set the type property: The type of the query. Please refer to the ScriptType for valid options. Type: string (or
* Expression with resultType string).
*
* @param type the type value to set.
* @return the ScriptActivityScriptBlock object itself.
*/
public ScriptActivityScriptBlock withType(Object type) {
this.type = type;
return this;
}
/**
* Get the parameters property: Array of script parameters. Type: array.
*
* @return the parameters value.
*/
public List parameters() {
return this.parameters;
}
/**
* Set the parameters property: Array of script parameters. Type: array.
*
* @param parameters the parameters value to set.
* @return the ScriptActivityScriptBlock object itself.
*/
public ScriptActivityScriptBlock withParameters(List parameters) {
this.parameters = parameters;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (text() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property text in model ScriptActivityScriptBlock"));
}
if (type() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property type in model ScriptActivityScriptBlock"));
}
if (parameters() != null) {
parameters().forEach(e -> e.validate());
}
}
private static final ClientLogger LOGGER = new ClientLogger(ScriptActivityScriptBlock.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeUntypedField("text", this.text);
jsonWriter.writeUntypedField("type", this.type);
jsonWriter.writeArrayField("parameters", this.parameters, (writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ScriptActivityScriptBlock from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ScriptActivityScriptBlock 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 ScriptActivityScriptBlock.
*/
public static ScriptActivityScriptBlock fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ScriptActivityScriptBlock deserializedScriptActivityScriptBlock = new ScriptActivityScriptBlock();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("text".equals(fieldName)) {
deserializedScriptActivityScriptBlock.text = reader.readUntyped();
} else if ("type".equals(fieldName)) {
deserializedScriptActivityScriptBlock.type = reader.readUntyped();
} else if ("parameters".equals(fieldName)) {
List parameters
= reader.readArray(reader1 -> ScriptActivityParameter.fromJson(reader1));
deserializedScriptActivityScriptBlock.parameters = parameters;
} else {
reader.skipChildren();
}
}
return deserializedScriptActivityScriptBlock;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy