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

com.azure.resourcemanager.hybridcompute.models.LicenseDetails Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for HybridCompute Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The Hybrid Compute Management Client. Package tag package-preview-2024-07.

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.hybridcompute.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;

/**
 * Describes the properties of a License.
 */
@Fluent
public final class LicenseDetails implements JsonSerializable {
    /*
     * Describes the state of the license.
     */
    private LicenseState state;

    /*
     * Describes the license target server.
     */
    private LicenseTarget target;

    /*
     * Describes the edition of the license. The values are either Standard or Datacenter.
     */
    private LicenseEdition edition;

    /*
     * Describes the license core type (pCore or vCore).
     */
    private LicenseCoreType type;

    /*
     * Describes the number of processors.
     */
    private Integer processors;

    /*
     * Describes the number of assigned licenses.
     */
    private Integer assignedLicenses;

    /*
     * Describes the immutable id.
     */
    private String immutableId;

    /*
     * A list of volume license details.
     */
    private List volumeLicenseDetails;

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

    /**
     * Get the state property: Describes the state of the license.
     * 
     * @return the state value.
     */
    public LicenseState state() {
        return this.state;
    }

    /**
     * Set the state property: Describes the state of the license.
     * 
     * @param state the state value to set.
     * @return the LicenseDetails object itself.
     */
    public LicenseDetails withState(LicenseState state) {
        this.state = state;
        return this;
    }

    /**
     * Get the target property: Describes the license target server.
     * 
     * @return the target value.
     */
    public LicenseTarget target() {
        return this.target;
    }

    /**
     * Set the target property: Describes the license target server.
     * 
     * @param target the target value to set.
     * @return the LicenseDetails object itself.
     */
    public LicenseDetails withTarget(LicenseTarget target) {
        this.target = target;
        return this;
    }

    /**
     * Get the edition property: Describes the edition of the license. The values are either Standard or Datacenter.
     * 
     * @return the edition value.
     */
    public LicenseEdition edition() {
        return this.edition;
    }

    /**
     * Set the edition property: Describes the edition of the license. The values are either Standard or Datacenter.
     * 
     * @param edition the edition value to set.
     * @return the LicenseDetails object itself.
     */
    public LicenseDetails withEdition(LicenseEdition edition) {
        this.edition = edition;
        return this;
    }

    /**
     * Get the type property: Describes the license core type (pCore or vCore).
     * 
     * @return the type value.
     */
    public LicenseCoreType type() {
        return this.type;
    }

    /**
     * Set the type property: Describes the license core type (pCore or vCore).
     * 
     * @param type the type value to set.
     * @return the LicenseDetails object itself.
     */
    public LicenseDetails withType(LicenseCoreType type) {
        this.type = type;
        return this;
    }

    /**
     * Get the processors property: Describes the number of processors.
     * 
     * @return the processors value.
     */
    public Integer processors() {
        return this.processors;
    }

    /**
     * Set the processors property: Describes the number of processors.
     * 
     * @param processors the processors value to set.
     * @return the LicenseDetails object itself.
     */
    public LicenseDetails withProcessors(Integer processors) {
        this.processors = processors;
        return this;
    }

    /**
     * Get the assignedLicenses property: Describes the number of assigned licenses.
     * 
     * @return the assignedLicenses value.
     */
    public Integer assignedLicenses() {
        return this.assignedLicenses;
    }

    /**
     * Get the immutableId property: Describes the immutable id.
     * 
     * @return the immutableId value.
     */
    public String immutableId() {
        return this.immutableId;
    }

    /**
     * Get the volumeLicenseDetails property: A list of volume license details.
     * 
     * @return the volumeLicenseDetails value.
     */
    public List volumeLicenseDetails() {
        return this.volumeLicenseDetails;
    }

    /**
     * Set the volumeLicenseDetails property: A list of volume license details.
     * 
     * @param volumeLicenseDetails the volumeLicenseDetails value to set.
     * @return the LicenseDetails object itself.
     */
    public LicenseDetails withVolumeLicenseDetails(List volumeLicenseDetails) {
        this.volumeLicenseDetails = volumeLicenseDetails;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (volumeLicenseDetails() != null) {
            volumeLicenseDetails().forEach(e -> e.validate());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString());
        jsonWriter.writeStringField("target", this.target == null ? null : this.target.toString());
        jsonWriter.writeStringField("edition", this.edition == null ? null : this.edition.toString());
        jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString());
        jsonWriter.writeNumberField("processors", this.processors);
        jsonWriter.writeArrayField("volumeLicenseDetails", this.volumeLicenseDetails,
            (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

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

                if ("state".equals(fieldName)) {
                    deserializedLicenseDetails.state = LicenseState.fromString(reader.getString());
                } else if ("target".equals(fieldName)) {
                    deserializedLicenseDetails.target = LicenseTarget.fromString(reader.getString());
                } else if ("edition".equals(fieldName)) {
                    deserializedLicenseDetails.edition = LicenseEdition.fromString(reader.getString());
                } else if ("type".equals(fieldName)) {
                    deserializedLicenseDetails.type = LicenseCoreType.fromString(reader.getString());
                } else if ("processors".equals(fieldName)) {
                    deserializedLicenseDetails.processors = reader.getNullable(JsonReader::getInt);
                } else if ("assignedLicenses".equals(fieldName)) {
                    deserializedLicenseDetails.assignedLicenses = reader.getNullable(JsonReader::getInt);
                } else if ("immutableId".equals(fieldName)) {
                    deserializedLicenseDetails.immutableId = reader.getString();
                } else if ("volumeLicenseDetails".equals(fieldName)) {
                    List volumeLicenseDetails
                        = reader.readArray(reader1 -> VolumeLicenseDetails.fromJson(reader1));
                    deserializedLicenseDetails.volumeLicenseDetails = volumeLicenseDetails;
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedLicenseDetails;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy