All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.machinelearning.models.Route Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for Machine Learning Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. These APIs allow end users to operate on Azure Machine Learning Workspace resources. Package tag package-2024-04.

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.machinelearning.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;

/**
 * The Route model.
 */
@Fluent
public final class Route implements JsonSerializable {
    /*
     * [Required] The path for the route.
     */
    private String path;

    /*
     * [Required] The port for the route.
     */
    private int port;

    /**
     * Creates an instance of Route class.
     */
    public Route() {
    }

    /**
     * Get the path property: [Required] The path for the route.
     * 
     * @return the path value.
     */
    public String path() {
        return this.path;
    }

    /**
     * Set the path property: [Required] The path for the route.
     * 
     * @param path the path value to set.
     * @return the Route object itself.
     */
    public Route withPath(String path) {
        this.path = path;
        return this;
    }

    /**
     * Get the port property: [Required] The port for the route.
     * 
     * @return the port value.
     */
    public int port() {
        return this.port;
    }

    /**
     * Set the port property: [Required] The port for the route.
     * 
     * @param port the port value to set.
     * @return the Route object itself.
     */
    public Route withPort(int port) {
        this.port = port;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (path() == null) {
            throw LOGGER.atError().log(new IllegalArgumentException("Missing required property path in model Route"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("path", this.path);
        jsonWriter.writeIntField("port", this.port);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of Route from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of Route 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 Route.
     */
    public static Route fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            Route deserializedRoute = new Route();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("path".equals(fieldName)) {
                    deserializedRoute.path = reader.getString();
                } else if ("port".equals(fieldName)) {
                    deserializedRoute.port = reader.getInt();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRoute;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy