
com.azure.resourcemanager.orbital.models.EndPoint 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.orbital.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;
/**
* Customer end point to store and retrieve data during a contact with the spacecraft.
*/
@Fluent
public final class EndPoint implements JsonSerializable {
/*
* IP Address (IPv4).
*/
private String ipAddress;
/*
* Name of an end point.
*/
private String endPointName;
/*
* TCP port to listen on to receive data.
*/
private String port;
/*
* Protocol either UDP or TCP.
*/
private Protocol protocol;
/**
* Creates an instance of EndPoint class.
*/
public EndPoint() {
}
/**
* Get the ipAddress property: IP Address (IPv4).
*
* @return the ipAddress value.
*/
public String ipAddress() {
return this.ipAddress;
}
/**
* Set the ipAddress property: IP Address (IPv4).
*
* @param ipAddress the ipAddress value to set.
* @return the EndPoint object itself.
*/
public EndPoint withIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
return this;
}
/**
* Get the endPointName property: Name of an end point.
*
* @return the endPointName value.
*/
public String endPointName() {
return this.endPointName;
}
/**
* Set the endPointName property: Name of an end point.
*
* @param endPointName the endPointName value to set.
* @return the EndPoint object itself.
*/
public EndPoint withEndPointName(String endPointName) {
this.endPointName = endPointName;
return this;
}
/**
* Get the port property: TCP port to listen on to receive data.
*
* @return the port value.
*/
public String port() {
return this.port;
}
/**
* Set the port property: TCP port to listen on to receive data.
*
* @param port the port value to set.
* @return the EndPoint object itself.
*/
public EndPoint withPort(String port) {
this.port = port;
return this;
}
/**
* Get the protocol property: Protocol either UDP or TCP.
*
* @return the protocol value.
*/
public Protocol protocol() {
return this.protocol;
}
/**
* Set the protocol property: Protocol either UDP or TCP.
*
* @param protocol the protocol value to set.
* @return the EndPoint object itself.
*/
public EndPoint withProtocol(Protocol protocol) {
this.protocol = protocol;
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 EndPoint"));
}
if (endPointName() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property endPointName in model EndPoint"));
}
if (port() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property port in model EndPoint"));
}
if (protocol() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property protocol in model EndPoint"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(EndPoint.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("ipAddress", this.ipAddress);
jsonWriter.writeStringField("endPointName", this.endPointName);
jsonWriter.writeStringField("port", this.port);
jsonWriter.writeStringField("protocol", this.protocol == null ? null : this.protocol.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of EndPoint from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of EndPoint 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 EndPoint.
*/
public static EndPoint fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
EndPoint deserializedEndPoint = new EndPoint();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("ipAddress".equals(fieldName)) {
deserializedEndPoint.ipAddress = reader.getString();
} else if ("endPointName".equals(fieldName)) {
deserializedEndPoint.endPointName = reader.getString();
} else if ("port".equals(fieldName)) {
deserializedEndPoint.port = reader.getString();
} else if ("protocol".equals(fieldName)) {
deserializedEndPoint.protocol = Protocol.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedEndPoint;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy