
com.azure.resourcemanager.applicationinsights.fluent.models.AnnotationInner 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.fluent.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;
/**
* Annotation associated with an application insights resource.
*/
@Fluent
public final class AnnotationInner implements JsonSerializable {
/*
* Name of annotation
*/
private String annotationName;
/*
* Category of annotation, free form
*/
private String category;
/*
* Time when event occurred
*/
private OffsetDateTime eventTime;
/*
* Unique Id for annotation
*/
private String id;
/*
* Serialized JSON object for detailed properties
*/
private String properties;
/*
* Related parent annotation if any
*/
private String relatedAnnotation;
/**
* Creates an instance of AnnotationInner class.
*/
public AnnotationInner() {
}
/**
* Get the annotationName property: Name of annotation.
*
* @return the annotationName value.
*/
public String annotationName() {
return this.annotationName;
}
/**
* Set the annotationName property: Name of annotation.
*
* @param annotationName the annotationName value to set.
* @return the AnnotationInner object itself.
*/
public AnnotationInner withAnnotationName(String annotationName) {
this.annotationName = annotationName;
return this;
}
/**
* Get the category property: Category of annotation, free form.
*
* @return the category value.
*/
public String category() {
return this.category;
}
/**
* Set the category property: Category of annotation, free form.
*
* @param category the category value to set.
* @return the AnnotationInner object itself.
*/
public AnnotationInner withCategory(String category) {
this.category = category;
return this;
}
/**
* Get the eventTime property: Time when event occurred.
*
* @return the eventTime value.
*/
public OffsetDateTime eventTime() {
return this.eventTime;
}
/**
* Set the eventTime property: Time when event occurred.
*
* @param eventTime the eventTime value to set.
* @return the AnnotationInner object itself.
*/
public AnnotationInner withEventTime(OffsetDateTime eventTime) {
this.eventTime = eventTime;
return this;
}
/**
* Get the id property: Unique Id for annotation.
*
* @return the id value.
*/
public String id() {
return this.id;
}
/**
* Set the id property: Unique Id for annotation.
*
* @param id the id value to set.
* @return the AnnotationInner object itself.
*/
public AnnotationInner withId(String id) {
this.id = id;
return this;
}
/**
* Get the properties property: Serialized JSON object for detailed properties.
*
* @return the properties value.
*/
public String properties() {
return this.properties;
}
/**
* Set the properties property: Serialized JSON object for detailed properties.
*
* @param properties the properties value to set.
* @return the AnnotationInner object itself.
*/
public AnnotationInner withProperties(String properties) {
this.properties = properties;
return this;
}
/**
* Get the relatedAnnotation property: Related parent annotation if any.
*
* @return the relatedAnnotation value.
*/
public String relatedAnnotation() {
return this.relatedAnnotation;
}
/**
* Set the relatedAnnotation property: Related parent annotation if any.
*
* @param relatedAnnotation the relatedAnnotation value to set.
* @return the AnnotationInner object itself.
*/
public AnnotationInner withRelatedAnnotation(String relatedAnnotation) {
this.relatedAnnotation = relatedAnnotation;
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("AnnotationName", this.annotationName);
jsonWriter.writeStringField("Category", this.category);
jsonWriter.writeStringField("EventTime",
this.eventTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.eventTime));
jsonWriter.writeStringField("Id", this.id);
jsonWriter.writeStringField("Properties", this.properties);
jsonWriter.writeStringField("RelatedAnnotation", this.relatedAnnotation);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of AnnotationInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AnnotationInner 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 AnnotationInner.
*/
public static AnnotationInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AnnotationInner deserializedAnnotationInner = new AnnotationInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("AnnotationName".equals(fieldName)) {
deserializedAnnotationInner.annotationName = reader.getString();
} else if ("Category".equals(fieldName)) {
deserializedAnnotationInner.category = reader.getString();
} else if ("EventTime".equals(fieldName)) {
deserializedAnnotationInner.eventTime = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("Id".equals(fieldName)) {
deserializedAnnotationInner.id = reader.getString();
} else if ("Properties".equals(fieldName)) {
deserializedAnnotationInner.properties = reader.getString();
} else if ("RelatedAnnotation".equals(fieldName)) {
deserializedAnnotationInner.relatedAnnotation = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedAnnotationInner;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy