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

com.azure.resourcemanager.servicelinker.models.BasicErrorDryrunPrerequisiteResult 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.servicelinker.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The represent of basic error.
 */
@Fluent
public final class BasicErrorDryrunPrerequisiteResult extends DryrunPrerequisiteResult {
    /*
     * The type of dryrun result.
     */
    private DryrunPrerequisiteResultType type = DryrunPrerequisiteResultType.BASIC_ERROR;

    /*
     * The error code.
     */
    private String code;

    /*
     * The error message.
     */
    private String message;

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

    /**
     * Get the type property: The type of dryrun result.
     * 
     * @return the type value.
     */
    @Override
    public DryrunPrerequisiteResultType type() {
        return this.type;
    }

    /**
     * Get the code property: The error code.
     * 
     * @return the code value.
     */
    public String code() {
        return this.code;
    }

    /**
     * Set the code property: The error code.
     * 
     * @param code the code value to set.
     * @return the BasicErrorDryrunPrerequisiteResult object itself.
     */
    public BasicErrorDryrunPrerequisiteResult withCode(String code) {
        this.code = code;
        return this;
    }

    /**
     * Get the message property: The error message.
     * 
     * @return the message value.
     */
    public String message() {
        return this.message;
    }

    /**
     * Set the message property: The error message.
     * 
     * @param message the message value to set.
     * @return the BasicErrorDryrunPrerequisiteResult object itself.
     */
    public BasicErrorDryrunPrerequisiteResult withMessage(String message) {
        this.message = message;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString());
        jsonWriter.writeStringField("code", this.code);
        jsonWriter.writeStringField("message", this.message);
        return jsonWriter.writeEndObject();
    }

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

                if ("type".equals(fieldName)) {
                    deserializedBasicErrorDryrunPrerequisiteResult.type
                        = DryrunPrerequisiteResultType.fromString(reader.getString());
                } else if ("code".equals(fieldName)) {
                    deserializedBasicErrorDryrunPrerequisiteResult.code = reader.getString();
                } else if ("message".equals(fieldName)) {
                    deserializedBasicErrorDryrunPrerequisiteResult.message = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedBasicErrorDryrunPrerequisiteResult;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy