
com.azure.resourcemanager.billing.models.AvailableBalanceProperties 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;
import java.util.List;
/**
* The Available Credit or Payment on Account Balance. The credit balance can be used to settle due or past due
* invoices.
*/
@Fluent
public final class AvailableBalanceProperties implements JsonSerializable {
/*
* Credit amount for immediate payment.
*/
private AvailableBalancePropertiesAmount amount;
/*
* The list of payments on accounts.
*/
private List paymentsOnAccount;
/*
* Total amount of payments on accounts.
*/
private AvailableBalancePropertiesTotalPaymentsOnAccount totalPaymentsOnAccount;
/**
* Creates an instance of AvailableBalanceProperties class.
*/
public AvailableBalanceProperties() {
}
/**
* Get the amount property: Credit amount for immediate payment.
*
* @return the amount value.
*/
public AvailableBalancePropertiesAmount amount() {
return this.amount;
}
/**
* Set the amount property: Credit amount for immediate payment.
*
* @param amount the amount value to set.
* @return the AvailableBalanceProperties object itself.
*/
public AvailableBalanceProperties withAmount(AvailableBalancePropertiesAmount amount) {
this.amount = amount;
return this;
}
/**
* Get the paymentsOnAccount property: The list of payments on accounts.
*
* @return the paymentsOnAccount value.
*/
public List paymentsOnAccount() {
return this.paymentsOnAccount;
}
/**
* Get the totalPaymentsOnAccount property: Total amount of payments on accounts.
*
* @return the totalPaymentsOnAccount value.
*/
public AvailableBalancePropertiesTotalPaymentsOnAccount totalPaymentsOnAccount() {
return this.totalPaymentsOnAccount;
}
/**
* Set the totalPaymentsOnAccount property: Total amount of payments on accounts.
*
* @param totalPaymentsOnAccount the totalPaymentsOnAccount value to set.
* @return the AvailableBalanceProperties object itself.
*/
public AvailableBalanceProperties
withTotalPaymentsOnAccount(AvailableBalancePropertiesTotalPaymentsOnAccount totalPaymentsOnAccount) {
this.totalPaymentsOnAccount = totalPaymentsOnAccount;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (amount() != null) {
amount().validate();
}
if (paymentsOnAccount() != null) {
paymentsOnAccount().forEach(e -> e.validate());
}
if (totalPaymentsOnAccount() != null) {
totalPaymentsOnAccount().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("amount", this.amount);
jsonWriter.writeJsonField("totalPaymentsOnAccount", this.totalPaymentsOnAccount);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of AvailableBalanceProperties from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AvailableBalanceProperties 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 AvailableBalanceProperties.
*/
public static AvailableBalanceProperties fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AvailableBalanceProperties deserializedAvailableBalanceProperties = new AvailableBalanceProperties();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("amount".equals(fieldName)) {
deserializedAvailableBalanceProperties.amount = AvailableBalancePropertiesAmount.fromJson(reader);
} else if ("paymentsOnAccount".equals(fieldName)) {
List paymentsOnAccount
= reader.readArray(reader1 -> PaymentOnAccount.fromJson(reader1));
deserializedAvailableBalanceProperties.paymentsOnAccount = paymentsOnAccount;
} else if ("totalPaymentsOnAccount".equals(fieldName)) {
deserializedAvailableBalanceProperties.totalPaymentsOnAccount
= AvailableBalancePropertiesTotalPaymentsOnAccount.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedAvailableBalanceProperties;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy