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

com.azure.resourcemanager.azurestackhci.models.PackageVersionInfo Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for AzureStackHci Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Azure Stack HCI management service. Package tag package-2024-04.

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

/**
 * Current version of each updatable component.
 */
@Fluent
public final class PackageVersionInfo implements JsonSerializable {
    /*
     * Package type
     */
    private String packageType;

    /*
     * Package version
     */
    private String version;

    /*
     * Last time this component was updated.
     */
    private OffsetDateTime lastUpdated;

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

    /**
     * Get the packageType property: Package type.
     * 
     * @return the packageType value.
     */
    public String packageType() {
        return this.packageType;
    }

    /**
     * Set the packageType property: Package type.
     * 
     * @param packageType the packageType value to set.
     * @return the PackageVersionInfo object itself.
     */
    public PackageVersionInfo withPackageType(String packageType) {
        this.packageType = packageType;
        return this;
    }

    /**
     * Get the version property: Package version.
     * 
     * @return the version value.
     */
    public String version() {
        return this.version;
    }

    /**
     * Set the version property: Package version.
     * 
     * @param version the version value to set.
     * @return the PackageVersionInfo object itself.
     */
    public PackageVersionInfo withVersion(String version) {
        this.version = version;
        return this;
    }

    /**
     * Get the lastUpdated property: Last time this component was updated.
     * 
     * @return the lastUpdated value.
     */
    public OffsetDateTime lastUpdated() {
        return this.lastUpdated;
    }

    /**
     * Set the lastUpdated property: Last time this component was updated.
     * 
     * @param lastUpdated the lastUpdated value to set.
     * @return the PackageVersionInfo object itself.
     */
    public PackageVersionInfo withLastUpdated(OffsetDateTime lastUpdated) {
        this.lastUpdated = lastUpdated;
        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("packageType", this.packageType);
        jsonWriter.writeStringField("version", this.version);
        jsonWriter.writeStringField("lastUpdated",
            this.lastUpdated == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastUpdated));
        return jsonWriter.writeEndObject();
    }

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

                if ("packageType".equals(fieldName)) {
                    deserializedPackageVersionInfo.packageType = reader.getString();
                } else if ("version".equals(fieldName)) {
                    deserializedPackageVersionInfo.version = reader.getString();
                } else if ("lastUpdated".equals(fieldName)) {
                    deserializedPackageVersionInfo.lastUpdated = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedPackageVersionInfo;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy