// 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.fasterxml.jackson.annotation.JsonProperty;

/** Customer end point to store and retrieve data during a contact with the spacecraft. */
@Fluent
public final class EndPoint {
    /*
     * IP Address (IPv4).
     */
    @JsonProperty(value = "ipAddress", required = true)
    private String ipAddress;

    /*
     * Name of an end point.
     */
    @JsonProperty(value = "endPointName", required = true)
    private String endPointName;

    /*
     * TCP port to listen on to receive data.
     */
    @JsonProperty(value = "port", required = true)
    private String port;

    /*
     * Protocol either UDP or TCP.
     */
    @JsonProperty(value = "protocol", required = true)
    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
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property ipAddress in model EndPoint"));
        }
        if (endPointName() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property endPointName in model EndPoint"));
        }
        if (port() == null) {
            throw LOGGER
                .logExceptionAsError(new IllegalArgumentException("Missing required property port in model EndPoint"));
        }
        if (protocol() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property protocol in model EndPoint"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(EndPoint.class);
}
