com.azure.resourcemanager.databoxedge.models.PeriodicTimerSourceInfo 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.databoxedge.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
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;
/**
* Periodic timer event source.
*/
@Fluent
public final class PeriodicTimerSourceInfo implements JsonSerializable {
/*
* The time of the day that results in a valid trigger. Schedule is computed with reference to the time specified
* upto seconds. If timezone is not specified the time will considered to be in device timezone. The value will
* always be returned as UTC time.
*/
private OffsetDateTime startTime;
/*
* Periodic frequency at which timer event needs to be raised. Supports daily, hourly, minutes, and seconds.
*/
private String schedule;
/*
* Topic where periodic events are published to IoT device.
*/
private String topic;
/**
* Creates an instance of PeriodicTimerSourceInfo class.
*/
public PeriodicTimerSourceInfo() {
}
/**
* Get the startTime property: The time of the day that results in a valid trigger. Schedule is computed with
* reference to the time specified upto seconds. If timezone is not specified the time will considered to be in
* device timezone. The value will always be returned as UTC time.
*
* @return the startTime value.
*/
public OffsetDateTime startTime() {
return this.startTime;
}
/**
* Set the startTime property: The time of the day that results in a valid trigger. Schedule is computed with
* reference to the time specified upto seconds. If timezone is not specified the time will considered to be in
* device timezone. The value will always be returned as UTC time.
*
* @param startTime the startTime value to set.
* @return the PeriodicTimerSourceInfo object itself.
*/
public PeriodicTimerSourceInfo withStartTime(OffsetDateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Get the schedule property: Periodic frequency at which timer event needs to be raised. Supports daily, hourly,
* minutes, and seconds.
*
* @return the schedule value.
*/
public String schedule() {
return this.schedule;
}
/**
* Set the schedule property: Periodic frequency at which timer event needs to be raised. Supports daily, hourly,
* minutes, and seconds.
*
* @param schedule the schedule value to set.
* @return the PeriodicTimerSourceInfo object itself.
*/
public PeriodicTimerSourceInfo withSchedule(String schedule) {
this.schedule = schedule;
return this;
}
/**
* Get the topic property: Topic where periodic events are published to IoT device.
*
* @return the topic value.
*/
public String topic() {
return this.topic;
}
/**
* Set the topic property: Topic where periodic events are published to IoT device.
*
* @param topic the topic value to set.
* @return the PeriodicTimerSourceInfo object itself.
*/
public PeriodicTimerSourceInfo withTopic(String topic) {
this.topic = topic;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (startTime() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property startTime in model PeriodicTimerSourceInfo"));
}
if (schedule() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property schedule in model PeriodicTimerSourceInfo"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(PeriodicTimerSourceInfo.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("startTime",
this.startTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTime));
jsonWriter.writeStringField("schedule", this.schedule);
jsonWriter.writeStringField("topic", this.topic);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of PeriodicTimerSourceInfo from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of PeriodicTimerSourceInfo 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.
* @throws IOException If an error occurs while reading the PeriodicTimerSourceInfo.
*/
public static PeriodicTimerSourceInfo fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
PeriodicTimerSourceInfo deserializedPeriodicTimerSourceInfo = new PeriodicTimerSourceInfo();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("startTime".equals(fieldName)) {
deserializedPeriodicTimerSourceInfo.startTime = reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
} else if ("schedule".equals(fieldName)) {
deserializedPeriodicTimerSourceInfo.schedule = reader.getString();
} else if ("topic".equals(fieldName)) {
deserializedPeriodicTimerSourceInfo.topic = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedPeriodicTimerSourceInfo;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy