com.azure.resourcemanager.mediaservices.models.InputDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-mediaservices Show documentation
Show all versions of azure-resourcemanager-mediaservices Show documentation
This package contains Microsoft Azure SDK for MediaServices Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. This Swagger was generated by the API Framework. Package tag package-account-2023-01.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.mediaservices.models;
import com.azure.core.annotation.Fluent;
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;
/**
* Base class for defining an input. Use sub classes of this class to specify tracks selections and related metadata.
*/
@Fluent
public class InputDefinition implements JsonSerializable {
/*
* The discriminator for derived types.
*/
private String odataType = "InputDefinition";
/*
* The list of TrackDescriptors which define the metadata and selection of tracks in the input.
*/
private List includedTracks;
/**
* Creates an instance of InputDefinition class.
*/
public InputDefinition() {
}
/**
* Get the odataType property: The discriminator for derived types.
*
* @return the odataType value.
*/
public String odataType() {
return this.odataType;
}
/**
* Get the includedTracks property: The list of TrackDescriptors which define the metadata and selection of tracks
* in the input.
*
* @return the includedTracks value.
*/
public List includedTracks() {
return this.includedTracks;
}
/**
* Set the includedTracks property: The list of TrackDescriptors which define the metadata and selection of tracks
* in the input.
*
* @param includedTracks the includedTracks value to set.
* @return the InputDefinition object itself.
*/
public InputDefinition withIncludedTracks(List includedTracks) {
this.includedTracks = includedTracks;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (includedTracks() != null) {
includedTracks().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("@odata.type", this.odataType);
jsonWriter.writeArrayField("includedTracks", this.includedTracks,
(writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of InputDefinition from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of InputDefinition 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 InputDefinition.
*/
public static InputDefinition 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 ("@odata.type".equals(fieldName)) {
discriminatorValue = readerToUse.getString();
break;
} else {
readerToUse.skipChildren();
}
}
// Use the discriminator value to determine which subtype should be deserialized.
if ("#Microsoft.Media.FromAllInputFile".equals(discriminatorValue)) {
return FromAllInputFile.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.FromEachInputFile".equals(discriminatorValue)) {
return FromEachInputFile.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.InputFile".equals(discriminatorValue)) {
return InputFile.fromJson(readerToUse.reset());
} else {
return fromJsonKnownDiscriminator(readerToUse.reset());
}
}
});
}
static InputDefinition fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
InputDefinition deserializedInputDefinition = new InputDefinition();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("@odata.type".equals(fieldName)) {
deserializedInputDefinition.odataType = reader.getString();
} else if ("includedTracks".equals(fieldName)) {
List includedTracks
= reader.readArray(reader1 -> TrackDescriptor.fromJson(reader1));
deserializedInputDefinition.includedTracks = includedTracks;
} else {
reader.skipChildren();
}
}
return deserializedInputDefinition;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy