com.azure.resourcemanager.hdinsight.models.Usage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-hdinsight Show documentation
Show all versions of azure-resourcemanager-hdinsight Show documentation
This package contains Microsoft Azure SDK for HDInsight Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. HDInsight Management Client. Package tag package-2024-08-preview.
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.hdinsight.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;
/**
* The details about the usage of a particular limited resource.
*/
@Fluent
public final class Usage implements JsonSerializable {
/*
* The type of measurement for usage.
*/
private String unit;
/*
* The current usage.
*/
private Long currentValue;
/*
* The maximum allowed usage.
*/
private Long limit;
/*
* The details about the localizable name of the used resource.
*/
private LocalizedName name;
/**
* Creates an instance of Usage class.
*/
public Usage() {
}
/**
* Get the unit property: The type of measurement for usage.
*
* @return the unit value.
*/
public String unit() {
return this.unit;
}
/**
* Set the unit property: The type of measurement for usage.
*
* @param unit the unit value to set.
* @return the Usage object itself.
*/
public Usage withUnit(String unit) {
this.unit = unit;
return this;
}
/**
* Get the currentValue property: The current usage.
*
* @return the currentValue value.
*/
public Long currentValue() {
return this.currentValue;
}
/**
* Set the currentValue property: The current usage.
*
* @param currentValue the currentValue value to set.
* @return the Usage object itself.
*/
public Usage withCurrentValue(Long currentValue) {
this.currentValue = currentValue;
return this;
}
/**
* Get the limit property: The maximum allowed usage.
*
* @return the limit value.
*/
public Long limit() {
return this.limit;
}
/**
* Set the limit property: The maximum allowed usage.
*
* @param limit the limit value to set.
* @return the Usage object itself.
*/
public Usage withLimit(Long limit) {
this.limit = limit;
return this;
}
/**
* Get the name property: The details about the localizable name of the used resource.
*
* @return the name value.
*/
public LocalizedName name() {
return this.name;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (name() != null) {
name().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("unit", this.unit);
jsonWriter.writeNumberField("currentValue", this.currentValue);
jsonWriter.writeNumberField("limit", this.limit);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of Usage from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of Usage 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 Usage.
*/
public static Usage fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
Usage deserializedUsage = new Usage();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("unit".equals(fieldName)) {
deserializedUsage.unit = reader.getString();
} else if ("currentValue".equals(fieldName)) {
deserializedUsage.currentValue = reader.getNullable(JsonReader::getLong);
} else if ("limit".equals(fieldName)) {
deserializedUsage.limit = reader.getNullable(JsonReader::getLong);
} else if ("name".equals(fieldName)) {
deserializedUsage.name = LocalizedName.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedUsage;
});
}
}