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

com.azure.resourcemanager.orbital.models.ContactParameters 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.orbital.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
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;

/**
 * Parameters that define the contact resource.
 */
@Fluent
public final class ContactParameters implements JsonSerializable {
    /*
     * The reference to the contact profile resource.
     */
    private ContactParametersContactProfile contactProfile;

    /*
     * Name of Azure Ground Station.
     */
    private String groundStationName;

    /*
     * Start time of a contact (ISO 8601 UTC standard).
     */
    private OffsetDateTime startTime;

    /*
     * End time of a contact (ISO 8601 UTC standard).
     */
    private OffsetDateTime endTime;

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

    /**
     * Get the contactProfile property: The reference to the contact profile resource.
     * 
     * @return the contactProfile value.
     */
    public ContactParametersContactProfile contactProfile() {
        return this.contactProfile;
    }

    /**
     * Set the contactProfile property: The reference to the contact profile resource.
     * 
     * @param contactProfile the contactProfile value to set.
     * @return the ContactParameters object itself.
     */
    public ContactParameters withContactProfile(ContactParametersContactProfile contactProfile) {
        this.contactProfile = contactProfile;
        return this;
    }

    /**
     * Get the groundStationName property: Name of Azure Ground Station.
     * 
     * @return the groundStationName value.
     */
    public String groundStationName() {
        return this.groundStationName;
    }

    /**
     * Set the groundStationName property: Name of Azure Ground Station.
     * 
     * @param groundStationName the groundStationName value to set.
     * @return the ContactParameters object itself.
     */
    public ContactParameters withGroundStationName(String groundStationName) {
        this.groundStationName = groundStationName;
        return this;
    }

    /**
     * Get the startTime property: Start time of a contact (ISO 8601 UTC standard).
     * 
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Set the startTime property: Start time of a contact (ISO 8601 UTC standard).
     * 
     * @param startTime the startTime value to set.
     * @return the ContactParameters object itself.
     */
    public ContactParameters withStartTime(OffsetDateTime startTime) {
        this.startTime = startTime;
        return this;
    }

    /**
     * Get the endTime property: End time of a contact (ISO 8601 UTC standard).
     * 
     * @return the endTime value.
     */
    public OffsetDateTime endTime() {
        return this.endTime;
    }

    /**
     * Set the endTime property: End time of a contact (ISO 8601 UTC standard).
     * 
     * @param endTime the endTime value to set.
     * @return the ContactParameters object itself.
     */
    public ContactParameters withEndTime(OffsetDateTime endTime) {
        this.endTime = endTime;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (contactProfile() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property contactProfile in model ContactParameters"));
        } else {
            contactProfile().validate();
        }
        if (groundStationName() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException(
                    "Missing required property groundStationName in model ContactParameters"));
        }
        if (startTime() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property startTime in model ContactParameters"));
        }
        if (endTime() == null) {
            throw LOGGER.atError()
                .log(new IllegalArgumentException("Missing required property endTime in model ContactParameters"));
        }
    }

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("contactProfile", this.contactProfile);
        jsonWriter.writeStringField("groundStationName", this.groundStationName);
        jsonWriter.writeStringField("startTime",
            this.startTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.startTime));
        jsonWriter.writeStringField("endTime",
            this.endTime == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.endTime));
        return jsonWriter.writeEndObject();
    }

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

                if ("contactProfile".equals(fieldName)) {
                    deserializedContactParameters.contactProfile = ContactParametersContactProfile.fromJson(reader);
                } else if ("groundStationName".equals(fieldName)) {
                    deserializedContactParameters.groundStationName = reader.getString();
                } else if ("startTime".equals(fieldName)) {
                    deserializedContactParameters.startTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else if ("endTime".equals(fieldName)) {
                    deserializedContactParameters.endTime = reader
                        .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString()));
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedContactParameters;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy