com.azure.resourcemanager.servicelinker.models.ResourceList 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 com.azure.resourcemanager.servicelinker.fluent.models.LinkerResourceInner;
import java.io.IOException;
import java.util.List;
/**
* The list of Linker.
*/
@Fluent
public final class ResourceList implements JsonSerializable {
/*
* The Linker used to get the next page of Linker list.
*/
private String nextLink;
/*
* The list of Linkers.
*/
private List value;
/**
* Creates an instance of ResourceList class.
*/
public ResourceList() {
}
/**
* Get the nextLink property: The Linker used to get the next page of Linker list.
*
* @return the nextLink value.
*/
public String nextLink() {
return this.nextLink;
}
/**
* Set the nextLink property: The Linker used to get the next page of Linker list.
*
* @param nextLink the nextLink value to set.
* @return the ResourceList object itself.
*/
public ResourceList withNextLink(String nextLink) {
this.nextLink = nextLink;
return this;
}
/**
* Get the value property: The list of Linkers.
*
* @return the value value.
*/
public List value() {
return this.value;
}
/**
* Set the value property: The list of Linkers.
*
* @param value the value value to set.
* @return the ResourceList object itself.
*/
public ResourceList withValue(List value) {
this.value = value;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (value() != null) {
value().forEach(e -> e.validate());
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("nextLink", this.nextLink);
jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element));
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ResourceList from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ResourceList 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 ResourceList.
*/
public static ResourceList fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ResourceList deserializedResourceList = new ResourceList();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("nextLink".equals(fieldName)) {
deserializedResourceList.nextLink = reader.getString();
} else if ("value".equals(fieldName)) {
List value
= reader.readArray(reader1 -> LinkerResourceInner.fromJson(reader1));
deserializedResourceList.value = value;
} else {
reader.skipChildren();
}
}
return deserializedResourceList;
});
}
}