All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.messaging.eventgrid.systemevents.MediaJobOutputCanceledEventData Maven / Gradle / Ivy

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.messaging.eventgrid.systemevents;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.Map;

/**
 * Job output canceled event data. Schema of the data property of an EventGridEvent for a
 * Microsoft.Media.JobOutputCanceled event.
 */
@Fluent
public final class MediaJobOutputCanceledEventData extends MediaJobOutputStateChangeEventData {
    /*
     * The previous state of the Job.
     */
    private MediaJobState previousState;

    /**
     * Creates an instance of MediaJobOutputCanceledEventData class.
     */
    public MediaJobOutputCanceledEventData() {
    }

    /**
     * Get the previousState property: The previous state of the Job.
     * 
     * @return the previousState value.
     */
    @Override
    public MediaJobState getPreviousState() {
        return this.previousState;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MediaJobOutputCanceledEventData setOutput(MediaJobOutput output) {
        super.setOutput(output);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MediaJobOutputCanceledEventData setJobCorrelationData(Map jobCorrelationData) {
        super.setJobCorrelationData(jobCorrelationData);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("output", getOutput());
        jsonWriter.writeMapField("jobCorrelationData", getJobCorrelationData(),
            (writer, element) -> writer.writeString(element));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of MediaJobOutputCanceledEventData from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of MediaJobOutputCanceledEventData 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 MediaJobOutputCanceledEventData.
     */
    public static MediaJobOutputCanceledEventData fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            MediaJobOutputCanceledEventData deserializedMediaJobOutputCanceledEventData
                = new MediaJobOutputCanceledEventData();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("previousState".equals(fieldName)) {
                    deserializedMediaJobOutputCanceledEventData.previousState
                        = MediaJobState.fromString(reader.getString());
                } else if ("output".equals(fieldName)) {
                    deserializedMediaJobOutputCanceledEventData.setOutput(MediaJobOutput.fromJson(reader));
                } else if ("jobCorrelationData".equals(fieldName)) {
                    Map jobCorrelationData = reader.readMap(reader1 -> reader1.getString());
                    deserializedMediaJobOutputCanceledEventData.setJobCorrelationData(jobCorrelationData);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedMediaJobOutputCanceledEventData;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy