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

com.azure.ai.metricsadvisor.implementation.models.MetricSeriesData 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.ai.metricsadvisor.implementation.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.time.OffsetDateTime;
import java.util.List;

/**
 * The MetricSeriesData model.
 */
@Fluent
public final class MetricSeriesData implements JsonSerializable {
    /*
     * The id property.
     */
    private MetricSeriesItem id;

    /*
     * timestamps of the data related to this time series
     */
    private List timestampList;

    /*
     * values of the data related to this time series
     */
    private List valueList;

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

    /**
     * Get the id property: The id property.
     * 
     * @return the id value.
     */
    public MetricSeriesItem getId() {
        return this.id;
    }

    /**
     * Set the id property: The id property.
     * 
     * @param id the id value to set.
     * @return the MetricSeriesData object itself.
     */
    public MetricSeriesData setId(MetricSeriesItem id) {
        this.id = id;
        return this;
    }

    /**
     * Get the timestampList property: timestamps of the data related to this time series.
     * 
     * @return the timestampList value.
     */
    public List getTimestampList() {
        return this.timestampList;
    }

    /**
     * Get the valueList property: values of the data related to this time series.
     * 
     * @return the valueList value.
     */
    public List getValueList() {
        return this.valueList;
    }

    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("id", this.id);
        return jsonWriter.writeEndObject();
    }

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

                if ("id".equals(fieldName)) {
                    deserializedMetricSeriesData.id = MetricSeriesItem.fromJson(reader);
                } else if ("timestampList".equals(fieldName)) {
                    List timestampList = reader.readArray(reader1 -> reader1
                        .getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())));
                    deserializedMetricSeriesData.timestampList = timestampList;
                } else if ("valueList".equals(fieldName)) {
                    List valueList = reader.readArray(reader1 -> reader1.getDouble());
                    deserializedMetricSeriesData.valueList = valueList;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedMetricSeriesData;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy