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

com.azure.resourcemanager.automation.fluent.models.ActivityProperties 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.automation.fluent.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 com.azure.resourcemanager.automation.models.ActivityOutputType;
import com.azure.resourcemanager.automation.models.ActivityParameterSet;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * Properties of the activity.
 */
@Fluent
public final class ActivityProperties implements JsonSerializable {
    /*
     * Gets or sets the user name of the activity.
     */
    private String definition;

    /*
     * Gets or sets the parameter sets of the activity.
     */
    private List parameterSets;

    /*
     * Gets or sets the output types of the activity.
     */
    private List outputTypes;

    /*
     * Gets or sets the creation time.
     */
    private OffsetDateTime creationTime;

    /*
     * Gets or sets the last modified time.
     */
    private OffsetDateTime lastModifiedTime;

    /*
     * Gets or sets the description.
     */
    private String description;

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

    /**
     * Get the definition property: Gets or sets the user name of the activity.
     * 
     * @return the definition value.
     */
    public String definition() {
        return this.definition;
    }

    /**
     * Set the definition property: Gets or sets the user name of the activity.
     * 
     * @param definition the definition value to set.
     * @return the ActivityProperties object itself.
     */
    public ActivityProperties withDefinition(String definition) {
        this.definition = definition;
        return this;
    }

    /**
     * Get the parameterSets property: Gets or sets the parameter sets of the activity.
     * 
     * @return the parameterSets value.
     */
    public List parameterSets() {
        return this.parameterSets;
    }

    /**
     * Set the parameterSets property: Gets or sets the parameter sets of the activity.
     * 
     * @param parameterSets the parameterSets value to set.
     * @return the ActivityProperties object itself.
     */
    public ActivityProperties withParameterSets(List parameterSets) {
        this.parameterSets = parameterSets;
        return this;
    }

    /**
     * Get the outputTypes property: Gets or sets the output types of the activity.
     * 
     * @return the outputTypes value.
     */
    public List outputTypes() {
        return this.outputTypes;
    }

    /**
     * Set the outputTypes property: Gets or sets the output types of the activity.
     * 
     * @param outputTypes the outputTypes value to set.
     * @return the ActivityProperties object itself.
     */
    public ActivityProperties withOutputTypes(List outputTypes) {
        this.outputTypes = outputTypes;
        return this;
    }

    /**
     * Get the creationTime property: Gets or sets the creation time.
     * 
     * @return the creationTime value.
     */
    public OffsetDateTime creationTime() {
        return this.creationTime;
    }

    /**
     * Set the creationTime property: Gets or sets the creation time.
     * 
     * @param creationTime the creationTime value to set.
     * @return the ActivityProperties object itself.
     */
    public ActivityProperties withCreationTime(OffsetDateTime creationTime) {
        this.creationTime = creationTime;
        return this;
    }

    /**
     * Get the lastModifiedTime property: Gets or sets the last modified time.
     * 
     * @return the lastModifiedTime value.
     */
    public OffsetDateTime lastModifiedTime() {
        return this.lastModifiedTime;
    }

    /**
     * Set the lastModifiedTime property: Gets or sets the last modified time.
     * 
     * @param lastModifiedTime the lastModifiedTime value to set.
     * @return the ActivityProperties object itself.
     */
    public ActivityProperties withLastModifiedTime(OffsetDateTime lastModifiedTime) {
        this.lastModifiedTime = lastModifiedTime;
        return this;
    }

    /**
     * Get the description property: Gets or sets the description.
     * 
     * @return the description value.
     */
    public String description() {
        return this.description;
    }

    /**
     * Set the description property: Gets or sets the description.
     * 
     * @param description the description value to set.
     * @return the ActivityProperties object itself.
     */
    public ActivityProperties withDescription(String description) {
        this.description = description;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("definition", this.definition);
        jsonWriter.writeArrayField("parameterSets", this.parameterSets, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeArrayField("outputTypes", this.outputTypes, (writer, element) -> writer.writeJson(element));
        jsonWriter.writeStringField("creationTime",
            this.creationTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.creationTime));
        jsonWriter.writeStringField("lastModifiedTime",
            this.lastModifiedTime == null
                ? null
                : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.lastModifiedTime));
        jsonWriter.writeStringField("description", this.description);
        return jsonWriter.writeEndObject();
    }

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

                if ("definition".equals(fieldName)) {
                    deserializedActivityProperties.definition = reader.getString();
                } else if ("parameterSets".equals(fieldName)) {
                    List parameterSets
                        = reader.readArray(reader1 -> ActivityParameterSet.fromJson(reader1));
                    deserializedActivityProperties.parameterSets = parameterSets;
                } else if ("outputTypes".equals(fieldName)) {
                    List outputTypes
                        = reader.readArray(reader1 -> ActivityOutputType.fromJson(reader1));
                    deserializedActivityProperties.outputTypes = outputTypes;
                } else if ("creationTime".equals(fieldName)) {
                    deserializedActivityProperties.creationTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("lastModifiedTime".equals(fieldName)) {
                    deserializedActivityProperties.lastModifiedTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("description".equals(fieldName)) {
                    deserializedActivityProperties.description = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedActivityProperties;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy