com.azure.ai.metricsadvisor.implementation.models.PeriodFeedback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-ai-metricsadvisor Show documentation
Show all versions of azure-ai-metricsadvisor Show documentation
This package contains the Microsoft Azure Cognitive Services Metrics Advisor SDK.
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.ai.metricsadvisor.models.FeedbackType;
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.time.OffsetDateTime;
import java.util.Objects;
import java.util.UUID;
/**
* The PeriodFeedback model.
*/
@Fluent
public final class PeriodFeedback extends MetricFeedback {
/*
* The value property.
*/
private PeriodFeedbackValue value;
/**
* Creates an instance of PeriodFeedback class.
*/
public PeriodFeedback() {
}
/**
* Get the value property: The value property.
*
* @return the value value.
*/
public PeriodFeedbackValue getValue() {
return this.value;
}
/**
* Set the value property: The value property.
*
* @param value the value value to set.
* @return the PeriodFeedback object itself.
*/
public PeriodFeedback setValue(PeriodFeedbackValue value) {
this.value = value;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public PeriodFeedback setMetricId(UUID metricId) {
super.setMetricId(metricId);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public PeriodFeedback setDimensionFilter(FeedbackDimensionFilter dimensionFilter) {
super.setDimensionFilter(dimensionFilter);
return this;
}
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("feedbackType",
FeedbackType.PERIOD == null ? null : FeedbackType.PERIOD.toString());
jsonWriter.writeStringField("metricId", Objects.toString(getMetricId(), null));
jsonWriter.writeJsonField("dimensionFilter", getDimensionFilter());
jsonWriter.writeJsonField("value", this.value);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of PeriodFeedback from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of PeriodFeedback if the JsonReader was pointing to an instance of it, or null if it was
* pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties or the
* polymorphic discriminator.
* @throws IOException If an error occurs while reading the PeriodFeedback.
*/
public static PeriodFeedback fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
PeriodFeedback deserializedPeriodFeedback = new PeriodFeedback();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("feedbackType".equals(fieldName)) {
String feedbackType = reader.getString();
if (!"Period".equals(feedbackType)) {
throw new IllegalStateException(
"'feedbackType' was expected to be non-null and equal to 'Period'. The found 'feedbackType' was '"
+ feedbackType + "'.");
}
} else if ("metricId".equals(fieldName)) {
deserializedPeriodFeedback
.setMetricId(reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())));
} else if ("dimensionFilter".equals(fieldName)) {
deserializedPeriodFeedback.setDimensionFilter(FeedbackDimensionFilter.fromJson(reader));
} else if ("feedbackId".equals(fieldName)) {
deserializedPeriodFeedback
.setFeedbackId(reader.getNullable(nonNullReader -> UUID.fromString(nonNullReader.getString())));
} else if ("createdTime".equals(fieldName)) {
deserializedPeriodFeedback.setCreatedTime(
reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())));
} else if ("userPrincipal".equals(fieldName)) {
deserializedPeriodFeedback.setUserPrincipal(reader.getString());
} else if ("value".equals(fieldName)) {
deserializedPeriodFeedback.value = PeriodFeedbackValue.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedPeriodFeedback;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy