com.azure.resourcemanager.mediaservices.models.Codec 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;
/**
* Describes the basic properties of all codecs.
*/
@Fluent
public class Codec implements JsonSerializable {
/*
* The discriminator for derived types.
*/
private String odataType = "Codec";
/*
* An optional label for the codec. The label can be used to control muxing behavior.
*/
private String label;
/**
* Creates an instance of Codec class.
*/
public Codec() {
}
/**
* Get the odataType property: The discriminator for derived types.
*
* @return the odataType value.
*/
public String odataType() {
return this.odataType;
}
/**
* Get the label property: An optional label for the codec. The label can be used to control muxing behavior.
*
* @return the label value.
*/
public String label() {
return this.label;
}
/**
* Set the label property: An optional label for the codec. The label can be used to control muxing behavior.
*
* @param label the label value to set.
* @return the Codec object itself.
*/
public Codec withLabel(String label) {
this.label = label;
return this;
}
/**
* 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("@odata.type", this.odataType);
jsonWriter.writeStringField("label", this.label);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of Codec from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of Codec 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 Codec.
*/
public static Codec 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.Audio".equals(discriminatorValue)) {
return Audio.fromJsonKnownDiscriminator(readerToUse.reset());
} else if ("#Microsoft.Media.AacAudio".equals(discriminatorValue)) {
return AacAudio.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.DDAudio".equals(discriminatorValue)) {
return DDAudio.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.Video".equals(discriminatorValue)) {
return Video.fromJsonKnownDiscriminator(readerToUse.reset());
} else if ("#Microsoft.Media.H265Video".equals(discriminatorValue)) {
return H265Video.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.Image".equals(discriminatorValue)) {
return Image.fromJsonKnownDiscriminator(readerToUse.reset());
} else if ("#Microsoft.Media.JpgImage".equals(discriminatorValue)) {
return JpgImage.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.PngImage".equals(discriminatorValue)) {
return PngImage.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.H264Video".equals(discriminatorValue)) {
return H264Video.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.CopyVideo".equals(discriminatorValue)) {
return CopyVideo.fromJson(readerToUse.reset());
} else if ("#Microsoft.Media.CopyAudio".equals(discriminatorValue)) {
return CopyAudio.fromJson(readerToUse.reset());
} else {
return fromJsonKnownDiscriminator(readerToUse.reset());
}
}
});
}
static Codec fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
Codec deserializedCodec = new Codec();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("@odata.type".equals(fieldName)) {
deserializedCodec.odataType = reader.getString();
} else if ("label".equals(fieldName)) {
deserializedCodec.label = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedCodec;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy