
com.azure.resourcemanager.datafactory.models.ForEachActivity 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.ForEachActivityTypeProperties;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* This activity is used for iterating over a collection and execute given activities.
*/
@Fluent
public final class ForEachActivity extends ControlActivity {
/*
* Type of activity.
*/
private String type = "ForEach";
/*
* ForEach activity properties.
*/
private ForEachActivityTypeProperties innerTypeProperties = new ForEachActivityTypeProperties();
/**
* Creates an instance of ForEachActivity class.
*/
public ForEachActivity() {
}
/**
* Get the type property: Type of activity.
*
* @return the type value.
*/
@Override
public String type() {
return this.type;
}
/**
* Get the innerTypeProperties property: ForEach activity properties.
*
* @return the innerTypeProperties value.
*/
private ForEachActivityTypeProperties innerTypeProperties() {
return this.innerTypeProperties;
}
/**
* {@inheritDoc}
*/
@Override
public ForEachActivity withName(String name) {
super.withName(name);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ForEachActivity withDescription(String description) {
super.withDescription(description);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ForEachActivity withState(ActivityState state) {
super.withState(state);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ForEachActivity withOnInactiveMarkAs(ActivityOnInactiveMarkAs onInactiveMarkAs) {
super.withOnInactiveMarkAs(onInactiveMarkAs);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ForEachActivity withDependsOn(List dependsOn) {
super.withDependsOn(dependsOn);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public ForEachActivity withUserProperties(List userProperties) {
super.withUserProperties(userProperties);
return this;
}
/**
* Get the isSequential property: Should the loop be executed in sequence or in parallel (max 50).
*
* @return the isSequential value.
*/
public Boolean isSequential() {
return this.innerTypeProperties() == null ? null : this.innerTypeProperties().isSequential();
}
/**
* Set the isSequential property: Should the loop be executed in sequence or in parallel (max 50).
*
* @param isSequential the isSequential value to set.
* @return the ForEachActivity object itself.
*/
public ForEachActivity withIsSequential(Boolean isSequential) {
if (this.innerTypeProperties() == null) {
this.innerTypeProperties = new ForEachActivityTypeProperties();
}
this.innerTypeProperties().withIsSequential(isSequential);
return this;
}
/**
* Get the batchCount property: Batch count to be used for controlling the number of parallel execution (when
* isSequential is set to false).
*
* @return the batchCount value.
*/
public Integer batchCount() {
return this.innerTypeProperties() == null ? null : this.innerTypeProperties().batchCount();
}
/**
* Set the batchCount property: Batch count to be used for controlling the number of parallel execution (when
* isSequential is set to false).
*
* @param batchCount the batchCount value to set.
* @return the ForEachActivity object itself.
*/
public ForEachActivity withBatchCount(Integer batchCount) {
if (this.innerTypeProperties() == null) {
this.innerTypeProperties = new ForEachActivityTypeProperties();
}
this.innerTypeProperties().withBatchCount(batchCount);
return this;
}
/**
* Get the items property: Collection to iterate.
*
* @return the items value.
*/
public Expression items() {
return this.innerTypeProperties() == null ? null : this.innerTypeProperties().items();
}
/**
* Set the items property: Collection to iterate.
*
* @param items the items value to set.
* @return the ForEachActivity object itself.
*/
public ForEachActivity withItems(Expression items) {
if (this.innerTypeProperties() == null) {
this.innerTypeProperties = new ForEachActivityTypeProperties();
}
this.innerTypeProperties().withItems(items);
return this;
}
/**
* Get the activities property: List of activities to execute .
*
* @return the activities value.
*/
public List activities() {
return this.innerTypeProperties() == null ? null : this.innerTypeProperties().activities();
}
/**
* Set the activities property: List of activities to execute .
*
* @param activities the activities value to set.
* @return the ForEachActivity object itself.
*/
public ForEachActivity withActivities(List activities) {
if (this.innerTypeProperties() == null) {
this.innerTypeProperties = new ForEachActivityTypeProperties();
}
this.innerTypeProperties().withActivities(activities);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
if (innerTypeProperties() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property innerTypeProperties in model ForEachActivity"));
} else {
innerTypeProperties().validate();
}
if (name() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property name in model ForEachActivity"));
}
if (dependsOn() != null) {
dependsOn().forEach(e -> e.validate());
}
if (userProperties() != null) {
userProperties().forEach(e -> e.validate());
}
}
private static final ClientLogger LOGGER = new ClientLogger(ForEachActivity.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", name());
jsonWriter.writeStringField("description", description());
jsonWriter.writeStringField("state", state() == null ? null : state().toString());
jsonWriter.writeStringField("onInactiveMarkAs",
onInactiveMarkAs() == null ? null : onInactiveMarkAs().toString());
jsonWriter.writeArrayField("dependsOn", dependsOn(), (writer, element) -> writer.writeJson(element));
jsonWriter.writeArrayField("userProperties", userProperties(), (writer, element) -> writer.writeJson(element));
jsonWriter.writeJsonField("typeProperties", this.innerTypeProperties);
jsonWriter.writeStringField("type", this.type);
if (additionalProperties() != null) {
for (Map.Entry additionalProperty : additionalProperties().entrySet()) {
jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
}
}
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ForEachActivity from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ForEachActivity 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 ForEachActivity.
*/
public static ForEachActivity fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ForEachActivity deserializedForEachActivity = new ForEachActivity();
Map additionalProperties = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedForEachActivity.withName(reader.getString());
} else if ("description".equals(fieldName)) {
deserializedForEachActivity.withDescription(reader.getString());
} else if ("state".equals(fieldName)) {
deserializedForEachActivity.withState(ActivityState.fromString(reader.getString()));
} else if ("onInactiveMarkAs".equals(fieldName)) {
deserializedForEachActivity
.withOnInactiveMarkAs(ActivityOnInactiveMarkAs.fromString(reader.getString()));
} else if ("dependsOn".equals(fieldName)) {
List dependsOn
= reader.readArray(reader1 -> ActivityDependency.fromJson(reader1));
deserializedForEachActivity.withDependsOn(dependsOn);
} else if ("userProperties".equals(fieldName)) {
List userProperties = reader.readArray(reader1 -> UserProperty.fromJson(reader1));
deserializedForEachActivity.withUserProperties(userProperties);
} else if ("typeProperties".equals(fieldName)) {
deserializedForEachActivity.innerTypeProperties = ForEachActivityTypeProperties.fromJson(reader);
} else if ("type".equals(fieldName)) {
deserializedForEachActivity.type = reader.getString();
} else {
if (additionalProperties == null) {
additionalProperties = new LinkedHashMap<>();
}
additionalProperties.put(fieldName, reader.readUntyped());
}
}
deserializedForEachActivity.withAdditionalProperties(additionalProperties);
return deserializedForEachActivity;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy