com.azure.resourcemanager.databoxedge.fluent.models.BandwidthScheduleProperties 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.fluent.models;
import com.azure.core.annotation.Fluent;
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 com.azure.resourcemanager.databoxedge.models.DayOfWeek;
import java.io.IOException;
import java.util.List;
/**
* The properties of the bandwidth schedule.
*/
@Fluent
public final class BandwidthScheduleProperties implements JsonSerializable {
/*
* The start time of the schedule in UTC.
*/
private String start;
/*
* The stop time of the schedule in UTC.
*/
private String stop;
/*
* The bandwidth rate in Mbps.
*/
private int rateInMbps;
/*
* The days of the week when this schedule is applicable.
*/
private List days;
/**
* Creates an instance of BandwidthScheduleProperties class.
*/
public BandwidthScheduleProperties() {
}
/**
* Get the start property: The start time of the schedule in UTC.
*
* @return the start value.
*/
public String start() {
return this.start;
}
/**
* Set the start property: The start time of the schedule in UTC.
*
* @param start the start value to set.
* @return the BandwidthScheduleProperties object itself.
*/
public BandwidthScheduleProperties withStart(String start) {
this.start = start;
return this;
}
/**
* Get the stop property: The stop time of the schedule in UTC.
*
* @return the stop value.
*/
public String stop() {
return this.stop;
}
/**
* Set the stop property: The stop time of the schedule in UTC.
*
* @param stop the stop value to set.
* @return the BandwidthScheduleProperties object itself.
*/
public BandwidthScheduleProperties withStop(String stop) {
this.stop = stop;
return this;
}
/**
* Get the rateInMbps property: The bandwidth rate in Mbps.
*
* @return the rateInMbps value.
*/
public int rateInMbps() {
return this.rateInMbps;
}
/**
* Set the rateInMbps property: The bandwidth rate in Mbps.
*
* @param rateInMbps the rateInMbps value to set.
* @return the BandwidthScheduleProperties object itself.
*/
public BandwidthScheduleProperties withRateInMbps(int rateInMbps) {
this.rateInMbps = rateInMbps;
return this;
}
/**
* Get the days property: The days of the week when this schedule is applicable.
*
* @return the days value.
*/
public List days() {
return this.days;
}
/**
* Set the days property: The days of the week when this schedule is applicable.
*
* @param days the days value to set.
* @return the BandwidthScheduleProperties object itself.
*/
public BandwidthScheduleProperties withDays(List days) {
this.days = days;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (start() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property start in model BandwidthScheduleProperties"));
}
if (stop() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property stop in model BandwidthScheduleProperties"));
}
if (days() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property days in model BandwidthScheduleProperties"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(BandwidthScheduleProperties.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("start", this.start);
jsonWriter.writeStringField("stop", this.stop);
jsonWriter.writeIntField("rateInMbps", this.rateInMbps);
jsonWriter.writeArrayField("days", this.days,
(writer, element) -> writer.writeString(element == null ? null : element.toString()));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of BandwidthScheduleProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of BandwidthScheduleProperties 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 BandwidthScheduleProperties.
*/
public static BandwidthScheduleProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
BandwidthScheduleProperties deserializedBandwidthScheduleProperties = new BandwidthScheduleProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("start".equals(fieldName)) {
deserializedBandwidthScheduleProperties.start = reader.getString();
} else if ("stop".equals(fieldName)) {
deserializedBandwidthScheduleProperties.stop = reader.getString();
} else if ("rateInMbps".equals(fieldName)) {
deserializedBandwidthScheduleProperties.rateInMbps = reader.getInt();
} else if ("days".equals(fieldName)) {
List days = reader.readArray(reader1 -> DayOfWeek.fromString(reader1.getString()));
deserializedBandwidthScheduleProperties.days = days;
} else {
reader.skipChildren();
}
}
return deserializedBandwidthScheduleProperties;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy