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

com.azure.resourcemanager.databoxedge.models.RoleSinkInfo 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.databoxedge.models;

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

/**
 * Compute role against which events will be raised.
 */
@Fluent
public final class RoleSinkInfo implements JsonSerializable {
    /*
     * Compute role ID.
     */
    private String roleId;

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

    /**
     * Get the roleId property: Compute role ID.
     * 
     * @return the roleId value.
     */
    public String roleId() {
        return this.roleId;
    }

    /**
     * Set the roleId property: Compute role ID.
     * 
     * @param roleId the roleId value to set.
     * @return the RoleSinkInfo object itself.
     */
    public RoleSinkInfo withRoleId(String roleId) {
        this.roleId = roleId;
        return this;
    }

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

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

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("roleId", this.roleId);
        return jsonWriter.writeEndObject();
    }

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

                if ("roleId".equals(fieldName)) {
                    deserializedRoleSinkInfo.roleId = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRoleSinkInfo;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy