com.azure.resourcemanager.servicelinker.models.ValidationResultItem 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.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* The validation item for a Linker.
*/
@Fluent
public final class ValidationResultItem implements JsonSerializable {
/*
* The validation item name.
*/
private String name;
/*
* The display name of validation item
*/
private String description;
/*
* The result of validation
*/
private ValidationResultStatus result;
/*
* The error message of validation result
*/
private String errorMessage;
/*
* The error code of validation result
*/
private String errorCode;
/**
* Creates an instance of ValidationResultItem class.
*/
public ValidationResultItem() {
}
/**
* Get the name property: The validation item name.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: The validation item name.
*
* @param name the name value to set.
* @return the ValidationResultItem object itself.
*/
public ValidationResultItem withName(String name) {
this.name = name;
return this;
}
/**
* Get the description property: The display name of validation item.
*
* @return the description value.
*/
public String description() {
return this.description;
}
/**
* Set the description property: The display name of validation item.
*
* @param description the description value to set.
* @return the ValidationResultItem object itself.
*/
public ValidationResultItem withDescription(String description) {
this.description = description;
return this;
}
/**
* Get the result property: The result of validation.
*
* @return the result value.
*/
public ValidationResultStatus result() {
return this.result;
}
/**
* Set the result property: The result of validation.
*
* @param result the result value to set.
* @return the ValidationResultItem object itself.
*/
public ValidationResultItem withResult(ValidationResultStatus result) {
this.result = result;
return this;
}
/**
* Get the errorMessage property: The error message of validation result.
*
* @return the errorMessage value.
*/
public String errorMessage() {
return this.errorMessage;
}
/**
* Set the errorMessage property: The error message of validation result.
*
* @param errorMessage the errorMessage value to set.
* @return the ValidationResultItem object itself.
*/
public ValidationResultItem withErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
return this;
}
/**
* Get the errorCode property: The error code of validation result.
*
* @return the errorCode value.
*/
public String errorCode() {
return this.errorCode;
}
/**
* Set the errorCode property: The error code of validation result.
*
* @param errorCode the errorCode value to set.
* @return the ValidationResultItem object itself.
*/
public ValidationResultItem withErrorCode(String errorCode) {
this.errorCode = errorCode;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeStringField("description", this.description);
jsonWriter.writeStringField("result", this.result == null ? null : this.result.toString());
jsonWriter.writeStringField("errorMessage", this.errorMessage);
jsonWriter.writeStringField("errorCode", this.errorCode);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ValidationResultItem from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ValidationResultItem 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 ValidationResultItem.
*/
public static ValidationResultItem fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ValidationResultItem deserializedValidationResultItem = new ValidationResultItem();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedValidationResultItem.name = reader.getString();
} else if ("description".equals(fieldName)) {
deserializedValidationResultItem.description = reader.getString();
} else if ("result".equals(fieldName)) {
deserializedValidationResultItem.result = ValidationResultStatus.fromString(reader.getString());
} else if ("errorMessage".equals(fieldName)) {
deserializedValidationResultItem.errorMessage = reader.getString();
} else if ("errorCode".equals(fieldName)) {
deserializedValidationResultItem.errorCode = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedValidationResultItem;
});
}
}