com.azure.resourcemanager.servicelinker.models.DryrunParameters 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.servicelinker.models;
import com.azure.core.annotation.Immutable;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* The parameters of the dryrun.
*/
@Immutable
public class DryrunParameters implements JsonSerializable {
/*
* The name of action for you dryrun job.
*/
private DryrunActionName actionName = DryrunActionName.fromString("DryrunParameters");
/**
* Creates an instance of DryrunParameters class.
*/
public DryrunParameters() {
}
/**
* Get the actionName property: The name of action for you dryrun job.
*
* @return the actionName value.
*/
public DryrunActionName actionName() {
return this.actionName;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("actionName", this.actionName == null ? null : this.actionName.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of DryrunParameters from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of DryrunParameters 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 DryrunParameters.
*/
public static DryrunParameters fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
String discriminatorValue = null;
try (JsonReader readerToUse = reader.bufferObject()) {
readerToUse.nextToken(); // Prepare for reading
while (readerToUse.nextToken() != JsonToken.END_OBJECT) {
String fieldName = readerToUse.getFieldName();
readerToUse.nextToken();
if ("actionName".equals(fieldName)) {
discriminatorValue = readerToUse.getString();
break;
} else {
readerToUse.skipChildren();
}
}
// Use the discriminator value to determine which subtype should be deserialized.
if ("createOrUpdate".equals(discriminatorValue)) {
return CreateOrUpdateDryrunParameters.fromJson(readerToUse.reset());
} else {
return fromJsonKnownDiscriminator(readerToUse.reset());
}
}
});
}
static DryrunParameters fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
DryrunParameters deserializedDryrunParameters = new DryrunParameters();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("actionName".equals(fieldName)) {
deserializedDryrunParameters.actionName = DryrunActionName.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedDryrunParameters;
});
}
}