com.azure.resourcemanager.dnsresolver.models.TargetDnsServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-dnsresolver Show documentation
Show all versions of azure-resourcemanager-dnsresolver Show documentation
This package contains Microsoft Azure SDK for DnsResolver Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The DNS Resolver Management Client. Package tag package-2022-07.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.dnsresolver.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 java.io.IOException;
/**
* Describes a server to forward the DNS queries to.
*/
@Fluent
public final class TargetDnsServer implements JsonSerializable {
/*
* DNS server IP address.
*/
private String ipAddress;
/*
* DNS server port.
*/
private Integer port;
/**
* Creates an instance of TargetDnsServer class.
*/
public TargetDnsServer() {
}
/**
* Get the ipAddress property: DNS server IP address.
*
* @return the ipAddress value.
*/
public String ipAddress() {
return this.ipAddress;
}
/**
* Set the ipAddress property: DNS server IP address.
*
* @param ipAddress the ipAddress value to set.
* @return the TargetDnsServer object itself.
*/
public TargetDnsServer withIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
return this;
}
/**
* Get the port property: DNS server port.
*
* @return the port value.
*/
public Integer port() {
return this.port;
}
/**
* Set the port property: DNS server port.
*
* @param port the port value to set.
* @return the TargetDnsServer object itself.
*/
public TargetDnsServer withPort(Integer port) {
this.port = port;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (ipAddress() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property ipAddress in model TargetDnsServer"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(TargetDnsServer.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("ipAddress", this.ipAddress);
jsonWriter.writeNumberField("port", this.port);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of TargetDnsServer from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of TargetDnsServer 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 TargetDnsServer.
*/
public static TargetDnsServer fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
TargetDnsServer deserializedTargetDnsServer = new TargetDnsServer();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("ipAddress".equals(fieldName)) {
deserializedTargetDnsServer.ipAddress = reader.getString();
} else if ("port".equals(fieldName)) {
deserializedTargetDnsServer.port = reader.getNullable(JsonReader::getInt);
} else {
reader.skipChildren();
}
}
return deserializedTargetDnsServer;
});
}
}