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

com.azure.resourcemanager.billing.models.BillingPropertyPropertiesSubscriptionServiceUsageAddress 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.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The address of the individual or organization where service subscription is being used. Available for agreement type
 * Microsoft Online Services Program. This property can be updated via patch.
 */
@Fluent
public final class BillingPropertyPropertiesSubscriptionServiceUsageAddress extends AddressDetails {
    /**
     * Creates an instance of BillingPropertyPropertiesSubscriptionServiceUsageAddress class.
     */
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withAddressLine1(String addressLine1) {
        super.withAddressLine1(addressLine1);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withAddressLine2(String addressLine2) {
        super.withAddressLine2(addressLine2);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withAddressLine3(String addressLine3) {
        super.withAddressLine3(addressLine3);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withCity(String city) {
        super.withCity(city);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withCompanyName(String companyName) {
        super.withCompanyName(companyName);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withCountry(String country) {
        super.withCountry(country);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withDistrict(String district) {
        super.withDistrict(district);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withEmail(String email) {
        super.withEmail(email);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withFirstName(String firstName) {
        super.withFirstName(firstName);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withLastName(String lastName) {
        super.withLastName(lastName);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withMiddleName(String middleName) {
        super.withMiddleName(middleName);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withPhoneNumber(String phoneNumber) {
        super.withPhoneNumber(phoneNumber);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withPostalCode(String postalCode) {
        super.withPostalCode(postalCode);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withRegion(String region) {
        super.withRegion(region);
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public BillingPropertyPropertiesSubscriptionServiceUsageAddress withIsValidAddress(Boolean isValidAddress) {
        super.withIsValidAddress(isValidAddress);
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (addressLine1() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property addressLine1 in model BillingPropertyPropertiesSubscriptionServiceUsageAddress"));
        }
        if (country() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property country in model BillingPropertyPropertiesSubscriptionServiceUsageAddress"));
        }
    }

    private static final ClientLogger LOGGER
        = new ClientLogger(BillingPropertyPropertiesSubscriptionServiceUsageAddress.class);

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("addressLine1", addressLine1());
        jsonWriter.writeStringField("country", country());
        jsonWriter.writeStringField("addressLine2", addressLine2());
        jsonWriter.writeStringField("addressLine3", addressLine3());
        jsonWriter.writeStringField("city", city());
        jsonWriter.writeStringField("companyName", companyName());
        jsonWriter.writeStringField("district", district());
        jsonWriter.writeStringField("email", email());
        jsonWriter.writeStringField("firstName", firstName());
        jsonWriter.writeStringField("lastName", lastName());
        jsonWriter.writeStringField("middleName", middleName());
        jsonWriter.writeStringField("phoneNumber", phoneNumber());
        jsonWriter.writeStringField("postalCode", postalCode());
        jsonWriter.writeStringField("region", region());
        jsonWriter.writeBooleanField("isValidAddress", isValidAddress());
        return jsonWriter.writeEndObject();
    }

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

                if ("addressLine1".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withAddressLine1(reader.getString());
                } else if ("country".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withCountry(reader.getString());
                } else if ("addressLine2".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withAddressLine2(reader.getString());
                } else if ("addressLine3".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withAddressLine3(reader.getString());
                } else if ("city".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress.withCity(reader.getString());
                } else if ("companyName".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withCompanyName(reader.getString());
                } else if ("district".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withDistrict(reader.getString());
                } else if ("email".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress.withEmail(reader.getString());
                } else if ("firstName".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withFirstName(reader.getString());
                } else if ("lastName".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withLastName(reader.getString());
                } else if ("middleName".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withMiddleName(reader.getString());
                } else if ("phoneNumber".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withPhoneNumber(reader.getString());
                } else if ("postalCode".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withPostalCode(reader.getString());
                } else if ("region".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress.withRegion(reader.getString());
                } else if ("isValidAddress".equals(fieldName)) {
                    deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress
                        .withIsValidAddress(reader.getNullable(JsonReader::getBoolean));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedBillingPropertyPropertiesSubscriptionServiceUsageAddress;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy