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

com.azure.resourcemanager.datafactory.models.RecurrenceSchedule 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.datafactory.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.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * The recurrence schedule.
 */
@Fluent
public final class RecurrenceSchedule implements JsonSerializable {
    /*
     * The minutes.
     */
    private List minutes;

    /*
     * The hours.
     */
    private List hours;

    /*
     * The days of the week.
     */
    private List weekDays;

    /*
     * The month days.
     */
    private List monthDays;

    /*
     * The monthly occurrences.
     */
    private List monthlyOccurrences;

    /*
     * The recurrence schedule.
     */
    private Map additionalProperties;

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

    /**
     * Get the minutes property: The minutes.
     * 
     * @return the minutes value.
     */
    public List minutes() {
        return this.minutes;
    }

    /**
     * Set the minutes property: The minutes.
     * 
     * @param minutes the minutes value to set.
     * @return the RecurrenceSchedule object itself.
     */
    public RecurrenceSchedule withMinutes(List minutes) {
        this.minutes = minutes;
        return this;
    }

    /**
     * Get the hours property: The hours.
     * 
     * @return the hours value.
     */
    public List hours() {
        return this.hours;
    }

    /**
     * Set the hours property: The hours.
     * 
     * @param hours the hours value to set.
     * @return the RecurrenceSchedule object itself.
     */
    public RecurrenceSchedule withHours(List hours) {
        this.hours = hours;
        return this;
    }

    /**
     * Get the weekDays property: The days of the week.
     * 
     * @return the weekDays value.
     */
    public List weekDays() {
        return this.weekDays;
    }

    /**
     * Set the weekDays property: The days of the week.
     * 
     * @param weekDays the weekDays value to set.
     * @return the RecurrenceSchedule object itself.
     */
    public RecurrenceSchedule withWeekDays(List weekDays) {
        this.weekDays = weekDays;
        return this;
    }

    /**
     * Get the monthDays property: The month days.
     * 
     * @return the monthDays value.
     */
    public List monthDays() {
        return this.monthDays;
    }

    /**
     * Set the monthDays property: The month days.
     * 
     * @param monthDays the monthDays value to set.
     * @return the RecurrenceSchedule object itself.
     */
    public RecurrenceSchedule withMonthDays(List monthDays) {
        this.monthDays = monthDays;
        return this;
    }

    /**
     * Get the monthlyOccurrences property: The monthly occurrences.
     * 
     * @return the monthlyOccurrences value.
     */
    public List monthlyOccurrences() {
        return this.monthlyOccurrences;
    }

    /**
     * Set the monthlyOccurrences property: The monthly occurrences.
     * 
     * @param monthlyOccurrences the monthlyOccurrences value to set.
     * @return the RecurrenceSchedule object itself.
     */
    public RecurrenceSchedule withMonthlyOccurrences(List monthlyOccurrences) {
        this.monthlyOccurrences = monthlyOccurrences;
        return this;
    }

    /**
     * Get the additionalProperties property: The recurrence schedule.
     * 
     * @return the additionalProperties value.
     */
    public Map additionalProperties() {
        return this.additionalProperties;
    }

    /**
     * Set the additionalProperties property: The recurrence schedule.
     * 
     * @param additionalProperties the additionalProperties value to set.
     * @return the RecurrenceSchedule object itself.
     */
    public RecurrenceSchedule withAdditionalProperties(Map additionalProperties) {
        this.additionalProperties = additionalProperties;
        return this;
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayField("minutes", this.minutes, (writer, element) -> writer.writeInt(element));
        jsonWriter.writeArrayField("hours", this.hours, (writer, element) -> writer.writeInt(element));
        jsonWriter.writeArrayField("weekDays", this.weekDays,
            (writer, element) -> writer.writeString(element == null ? null : element.toString()));
        jsonWriter.writeArrayField("monthDays", this.monthDays, (writer, element) -> writer.writeInt(element));
        jsonWriter.writeArrayField("monthlyOccurrences", this.monthlyOccurrences,
            (writer, element) -> writer.writeJson(element));
        if (additionalProperties != null) {
            for (Map.Entry additionalProperty : additionalProperties.entrySet()) {
                jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
            }
        }
        return jsonWriter.writeEndObject();
    }

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

                if ("minutes".equals(fieldName)) {
                    List minutes = reader.readArray(reader1 -> reader1.getInt());
                    deserializedRecurrenceSchedule.minutes = minutes;
                } else if ("hours".equals(fieldName)) {
                    List hours = reader.readArray(reader1 -> reader1.getInt());
                    deserializedRecurrenceSchedule.hours = hours;
                } else if ("weekDays".equals(fieldName)) {
                    List weekDays = reader.readArray(reader1 -> DaysOfWeek.fromString(reader1.getString()));
                    deserializedRecurrenceSchedule.weekDays = weekDays;
                } else if ("monthDays".equals(fieldName)) {
                    List monthDays = reader.readArray(reader1 -> reader1.getInt());
                    deserializedRecurrenceSchedule.monthDays = monthDays;
                } else if ("monthlyOccurrences".equals(fieldName)) {
                    List monthlyOccurrences
                        = reader.readArray(reader1 -> RecurrenceScheduleOccurrence.fromJson(reader1));
                    deserializedRecurrenceSchedule.monthlyOccurrences = monthlyOccurrences;
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

                    additionalProperties.put(fieldName, reader.readUntyped());
                }
            }
            deserializedRecurrenceSchedule.additionalProperties = additionalProperties;

            return deserializedRecurrenceSchedule;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy