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

com.azure.resourcemanager.billing.models.PaymentTerm 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.core.util.CoreUtils;
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.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/**
 * The properties of payment term.
 */
@Fluent
public class PaymentTerm implements JsonSerializable {
    /*
     * Represents duration in netXX format. Always in days.
     */
    private String term;

    /*
     * The date on when the defined 'Payment Term' will be effective from and is always in UTC.
     */
    private OffsetDateTime startDate;

    /*
     * The date on when the defined 'Payment Term' will end and is always in UTC.
     */
    private OffsetDateTime endDate;

    /*
     * Indicates payment term is the standard payment term.
     */
    private Boolean isDefault;

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

    /**
     * Get the term property: Represents duration in netXX format. Always in days.
     * 
     * @return the term value.
     */
    public String term() {
        return this.term;
    }

    /**
     * Set the term property: Represents duration in netXX format. Always in days.
     * 
     * @param term the term value to set.
     * @return the PaymentTerm object itself.
     */
    public PaymentTerm withTerm(String term) {
        this.term = term;
        return this;
    }

    /**
     * Get the startDate property: The date on when the defined 'Payment Term' will be effective from and is always in
     * UTC.
     * 
     * @return the startDate value.
     */
    public OffsetDateTime startDate() {
        return this.startDate;
    }

    /**
     * Set the startDate property: The date on when the defined 'Payment Term' will be effective from and is always in
     * UTC.
     * 
     * @param startDate the startDate value to set.
     * @return the PaymentTerm object itself.
     */
    public PaymentTerm withStartDate(OffsetDateTime startDate) {
        this.startDate = startDate;
        return this;
    }

    /**
     * Get the endDate property: The date on when the defined 'Payment Term' will end and is always in UTC.
     * 
     * @return the endDate value.
     */
    public OffsetDateTime endDate() {
        return this.endDate;
    }

    /**
     * Set the endDate property: The date on when the defined 'Payment Term' will end and is always in UTC.
     * 
     * @param endDate the endDate value to set.
     * @return the PaymentTerm object itself.
     */
    public PaymentTerm withEndDate(OffsetDateTime endDate) {
        this.endDate = endDate;
        return this;
    }

    /**
     * Get the isDefault property: Indicates payment term is the standard payment term.
     * 
     * @return the isDefault value.
     */
    public Boolean isDefault() {
        return this.isDefault;
    }

    /**
     * Set the isDefault property: Indicates payment term is the standard payment term.
     * 
     * @param isDefault the isDefault value to set.
     * @return the PaymentTerm object itself.
     */
    PaymentTerm withIsDefault(Boolean isDefault) {
        this.isDefault = isDefault;
        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("term", this.term);
        jsonWriter.writeStringField("startDate",
            this.startDate == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startDate));
        jsonWriter.writeStringField("endDate",
            this.endDate == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endDate));
        return jsonWriter.writeEndObject();
    }

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

                if ("term".equals(fieldName)) {
                    deserializedPaymentTerm.term = reader.getString();
                } else if ("startDate".equals(fieldName)) {
                    deserializedPaymentTerm.startDate = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endDate".equals(fieldName)) {
                    deserializedPaymentTerm.endDate = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("isDefault".equals(fieldName)) {
                    deserializedPaymentTerm.isDefault = reader.getNullable(JsonReader::getBoolean);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPaymentTerm;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy