
com.azure.resourcemanager.appcontainers.models.EnvironmentVariable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-appcontainers Show documentation
Show all versions of azure-resourcemanager-appcontainers Show documentation
This package contains Microsoft Azure SDK for ContainerAppsApi Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package tag package-2024-03.
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.appcontainers.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;
/**
* Model representing an environment variable.
*/
@Fluent
public final class EnvironmentVariable implements JsonSerializable {
/*
* Environment variable name.
*/
private String name;
/*
* Environment variable value.
*/
private String value;
/**
* Creates an instance of EnvironmentVariable class.
*/
public EnvironmentVariable() {
}
/**
* Get the name property: Environment variable name.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: Environment variable name.
*
* @param name the name value to set.
* @return the EnvironmentVariable object itself.
*/
public EnvironmentVariable withName(String name) {
this.name = name;
return this;
}
/**
* Get the value property: Environment variable value.
*
* @return the value value.
*/
public String value() {
return this.value;
}
/**
* Set the value property: Environment variable value.
*
* @param value the value value to set.
* @return the EnvironmentVariable object itself.
*/
public EnvironmentVariable withValue(String value) {
this.value = value;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (name() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property name in model EnvironmentVariable"));
}
if (value() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property value in model EnvironmentVariable"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(EnvironmentVariable.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("value", this.value);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of EnvironmentVariable from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of EnvironmentVariable 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 EnvironmentVariable.
*/
public static EnvironmentVariable fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
EnvironmentVariable deserializedEnvironmentVariable = new EnvironmentVariable();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedEnvironmentVariable.name = reader.getString();
} else if ("value".equals(fieldName)) {
deserializedEnvironmentVariable.value = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedEnvironmentVariable;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy