
com.azure.resourcemanager.billing.models.ProductDetails 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.billing.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;
/**
* Details of the product that is transferred.
*/
@Fluent
public final class ProductDetails implements JsonSerializable {
/*
* Type of the product that is transferred.
*/
private ProductType productType;
/*
* The ID of the product that is transferred.
*/
private String productId;
/**
* Creates an instance of ProductDetails class.
*/
public ProductDetails() {
}
/**
* Get the productType property: Type of the product that is transferred.
*
* @return the productType value.
*/
public ProductType productType() {
return this.productType;
}
/**
* Set the productType property: Type of the product that is transferred.
*
* @param productType the productType value to set.
* @return the ProductDetails object itself.
*/
public ProductDetails withProductType(ProductType productType) {
this.productType = productType;
return this;
}
/**
* Get the productId property: The ID of the product that is transferred.
*
* @return the productId value.
*/
public String productId() {
return this.productId;
}
/**
* Set the productId property: The ID of the product that is transferred.
*
* @param productId the productId value to set.
* @return the ProductDetails object itself.
*/
public ProductDetails withProductId(String productId) {
this.productId = productId;
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("productType", this.productType == null ? null : this.productType.toString());
jsonWriter.writeStringField("productId", this.productId);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ProductDetails from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ProductDetails 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 ProductDetails.
*/
public static ProductDetails fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ProductDetails deserializedProductDetails = new ProductDetails();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("productType".equals(fieldName)) {
deserializedProductDetails.productType = ProductType.fromString(reader.getString());
} else if ("productId".equals(fieldName)) {
deserializedProductDetails.productId = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedProductDetails;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy