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

com.azure.resourcemanager.network.models.StaticRoute 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.network.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;
import java.util.List;

/**
 * List of all Static Routes.
 */
@Fluent
public final class StaticRoute implements JsonSerializable {
    /*
     * The name of the StaticRoute that is unique within a VnetRoute.
     */
    private String name;

    /*
     * List of all address prefixes.
     */
    private List addressPrefixes;

    /*
     * The ip address of the next hop.
     */
    private String nextHopIpAddress;

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

    /**
     * Get the name property: The name of the StaticRoute that is unique within a VnetRoute.
     * 
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: The name of the StaticRoute that is unique within a VnetRoute.
     * 
     * @param name the name value to set.
     * @return the StaticRoute object itself.
     */
    public StaticRoute withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the addressPrefixes property: List of all address prefixes.
     * 
     * @return the addressPrefixes value.
     */
    public List addressPrefixes() {
        return this.addressPrefixes;
    }

    /**
     * Set the addressPrefixes property: List of all address prefixes.
     * 
     * @param addressPrefixes the addressPrefixes value to set.
     * @return the StaticRoute object itself.
     */
    public StaticRoute withAddressPrefixes(List addressPrefixes) {
        this.addressPrefixes = addressPrefixes;
        return this;
    }

    /**
     * Get the nextHopIpAddress property: The ip address of the next hop.
     * 
     * @return the nextHopIpAddress value.
     */
    public String nextHopIpAddress() {
        return this.nextHopIpAddress;
    }

    /**
     * Set the nextHopIpAddress property: The ip address of the next hop.
     * 
     * @param nextHopIpAddress the nextHopIpAddress value to set.
     * @return the StaticRoute object itself.
     */
    public StaticRoute withNextHopIpAddress(String nextHopIpAddress) {
        this.nextHopIpAddress = nextHopIpAddress;
        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.writeArrayField("addressPrefixes", this.addressPrefixes,
            (writer, element) -> writer.writeString(element));
        jsonWriter.writeStringField("nextHopIpAddress", this.nextHopIpAddress);
        return jsonWriter.writeEndObject();
    }

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

                if ("name".equals(fieldName)) {
                    deserializedStaticRoute.name = reader.getString();
                } else if ("addressPrefixes".equals(fieldName)) {
                    List addressPrefixes = reader.readArray(reader1 -> reader1.getString());
                    deserializedStaticRoute.addressPrefixes = addressPrefixes;
                } else if ("nextHopIpAddress".equals(fieldName)) {
                    deserializedStaticRoute.nextHopIpAddress = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedStaticRoute;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy