
com.azure.resourcemanager.datafactory.models.SwitchActivity 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.SwitchActivityTypeProperties;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* This activity evaluates an expression and executes activities under the cases property that correspond to the
* expression evaluation expected in the equals property.
*/
@Fluent
public final class SwitchActivity extends ControlActivity {
/*
* Type of activity.
*/
private String type = "Switch";
/*
* Switch activity properties.
*/
private SwitchActivityTypeProperties innerTypeProperties = new SwitchActivityTypeProperties();
/**
* Creates an instance of SwitchActivity class.
*/
public SwitchActivity() {
}
/**
* Get the type property: Type of activity.
*
* @return the type value.
*/
@Override
public String type() {
return this.type;
}
/**
* Get the innerTypeProperties property: Switch activity properties.
*
* @return the innerTypeProperties value.
*/
private SwitchActivityTypeProperties innerTypeProperties() {
return this.innerTypeProperties;
}
/**
* {@inheritDoc}
*/
@Override
public SwitchActivity withName(String name) {
super.withName(name);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public SwitchActivity withDescription(String description) {
super.withDescription(description);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public SwitchActivity withState(ActivityState state) {
super.withState(state);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public SwitchActivity withOnInactiveMarkAs(ActivityOnInactiveMarkAs onInactiveMarkAs) {
super.withOnInactiveMarkAs(onInactiveMarkAs);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public SwitchActivity withDependsOn(List dependsOn) {
super.withDependsOn(dependsOn);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public SwitchActivity withUserProperties(List userProperties) {
super.withUserProperties(userProperties);
return this;
}
/**
* Get the on property: An expression that would evaluate to a string or integer. This is used to determine the
* block of activities in cases that will be executed.
*
* @return the on value.
*/
public Expression on() {
return this.innerTypeProperties() == null ? null : this.innerTypeProperties().on();
}
/**
* Set the on property: An expression that would evaluate to a string or integer. This is used to determine the
* block of activities in cases that will be executed.
*
* @param on the on value to set.
* @return the SwitchActivity object itself.
*/
public SwitchActivity withOn(Expression on) {
if (this.innerTypeProperties() == null) {
this.innerTypeProperties = new SwitchActivityTypeProperties();
}
this.innerTypeProperties().withOn(on);
return this;
}
/**
* Get the cases property: List of cases that correspond to expected values of the 'on' property. This is an
* optional property and if not provided, the activity will execute activities provided in defaultActivities.
*
* @return the cases value.
*/
public List cases() {
return this.innerTypeProperties() == null ? null : this.innerTypeProperties().cases();
}
/**
* Set the cases property: List of cases that correspond to expected values of the 'on' property. This is an
* optional property and if not provided, the activity will execute activities provided in defaultActivities.
*
* @param cases the cases value to set.
* @return the SwitchActivity object itself.
*/
public SwitchActivity withCases(List cases) {
if (this.innerTypeProperties() == null) {
this.innerTypeProperties = new SwitchActivityTypeProperties();
}
this.innerTypeProperties().withCases(cases);
return this;
}
/**
* Get the defaultActivities property: List of activities to execute if no case condition is satisfied. This is an
* optional property and if not provided, the activity will exit without any action.
*
* @return the defaultActivities value.
*/
public List defaultActivities() {
return this.innerTypeProperties() == null ? null : this.innerTypeProperties().defaultActivities();
}
/**
* Set the defaultActivities property: List of activities to execute if no case condition is satisfied. This is an
* optional property and if not provided, the activity will exit without any action.
*
* @param defaultActivities the defaultActivities value to set.
* @return the SwitchActivity object itself.
*/
public SwitchActivity withDefaultActivities(List defaultActivities) {
if (this.innerTypeProperties() == null) {
this.innerTypeProperties = new SwitchActivityTypeProperties();
}
this.innerTypeProperties().withDefaultActivities(defaultActivities);
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 SwitchActivity"));
} else {
innerTypeProperties().validate();
}
if (name() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property name in model SwitchActivity"));
}
if (dependsOn() != null) {
dependsOn().forEach(e -> e.validate());
}
if (userProperties() != null) {
userProperties().forEach(e -> e.validate());
}
}
private static final ClientLogger LOGGER = new ClientLogger(SwitchActivity.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 SwitchActivity from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of SwitchActivity 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 SwitchActivity.
*/
public static SwitchActivity fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
SwitchActivity deserializedSwitchActivity = new SwitchActivity();
Map additionalProperties = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedSwitchActivity.withName(reader.getString());
} else if ("description".equals(fieldName)) {
deserializedSwitchActivity.withDescription(reader.getString());
} else if ("state".equals(fieldName)) {
deserializedSwitchActivity.withState(ActivityState.fromString(reader.getString()));
} else if ("onInactiveMarkAs".equals(fieldName)) {
deserializedSwitchActivity
.withOnInactiveMarkAs(ActivityOnInactiveMarkAs.fromString(reader.getString()));
} else if ("dependsOn".equals(fieldName)) {
List dependsOn
= reader.readArray(reader1 -> ActivityDependency.fromJson(reader1));
deserializedSwitchActivity.withDependsOn(dependsOn);
} else if ("userProperties".equals(fieldName)) {
List userProperties = reader.readArray(reader1 -> UserProperty.fromJson(reader1));
deserializedSwitchActivity.withUserProperties(userProperties);
} else if ("typeProperties".equals(fieldName)) {
deserializedSwitchActivity.innerTypeProperties = SwitchActivityTypeProperties.fromJson(reader);
} else if ("type".equals(fieldName)) {
deserializedSwitchActivity.type = reader.getString();
} else {
if (additionalProperties == null) {
additionalProperties = new LinkedHashMap<>();
}
additionalProperties.put(fieldName, reader.readUntyped());
}
}
deserializedSwitchActivity.withAdditionalProperties(additionalProperties);
return deserializedSwitchActivity;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy