
com.azure.resourcemanager.applicationinsights.models.InnerError Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.applicationinsights.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
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.time.format.DateTimeFormatter;
/**
* Inner error.
*/
@Fluent
public final class InnerError implements JsonSerializable {
/*
* Provides correlation for request
*/
private String diagnosticcontext;
/*
* Request time
*/
private OffsetDateTime time;
/**
* Creates an instance of InnerError class.
*/
public InnerError() {
}
/**
* Get the diagnosticcontext property: Provides correlation for request.
*
* @return the diagnosticcontext value.
*/
public String diagnosticcontext() {
return this.diagnosticcontext;
}
/**
* Set the diagnosticcontext property: Provides correlation for request.
*
* @param diagnosticcontext the diagnosticcontext value to set.
* @return the InnerError object itself.
*/
public InnerError withDiagnosticcontext(String diagnosticcontext) {
this.diagnosticcontext = diagnosticcontext;
return this;
}
/**
* Get the time property: Request time.
*
* @return the time value.
*/
public OffsetDateTime time() {
return this.time;
}
/**
* Set the time property: Request time.
*
* @param time the time value to set.
* @return the InnerError object itself.
*/
public InnerError withTime(OffsetDateTime time) {
this.time = time;
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("diagnosticcontext", this.diagnosticcontext);
jsonWriter.writeStringField("time",
this.time == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.time));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of InnerError from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of InnerError 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 InnerError.
*/
public static InnerError fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
InnerError deserializedInnerError = new InnerError();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("diagnosticcontext".equals(fieldName)) {
deserializedInnerError.diagnosticcontext = reader.getString();
} else if ("time".equals(fieldName)) {
deserializedInnerError.time = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else {
reader.skipChildren();
}
}
return deserializedInnerError;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy