com.azure.resourcemanager.deviceupdate.models.Location Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-deviceupdate Show documentation
Show all versions of azure-resourcemanager-deviceupdate Show documentation
This package contains Microsoft Azure SDK for DeviceUpdate Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Microsoft Device Update resource provider. Package tag package-2023-07-01.
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.resourcemanager.deviceupdate.models;
import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* The Location model.
*/
@Fluent
public final class Location implements JsonSerializable {
/*
* The name property.
*/
private String name;
/*
* Whether the location is primary or failover
*/
private Role role;
/**
* Creates an instance of Location class.
*/
public Location() {
}
/**
* Get the name property: The name property.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: The name property.
*
* @param name the name value to set.
* @return the Location object itself.
*/
public Location withName(String name) {
this.name = name;
return this;
}
/**
* Get the role property: Whether the location is primary or failover.
*
* @return the role value.
*/
public Role role() {
return this.role;
}
/**
* Set the role property: Whether the location is primary or failover.
*
* @param role the role value to set.
* @return the Location object itself.
*/
public Location withRole(Role role) {
this.role = role;
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("name", this.name);
jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of Location from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of Location 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 Location.
*/
public static Location fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
Location deserializedLocation = new Location();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedLocation.name = reader.getString();
} else if ("role".equals(fieldName)) {
deserializedLocation.role = Role.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedLocation;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy