com.azure.resourcemanager.servicefabricmanagedclusters.models.NamedPartitionScheme Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-servicefabricmanagedclusters Show documentation
Show all versions of azure-resourcemanager-servicefabricmanagedclusters Show documentation
This package contains Microsoft Azure SDK for Service Fabric Managed Clusters Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Service Fabric Managed Clusters Management Client. Package tag package-2024-04.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.servicefabricmanagedclusters.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;
/**
* Describes the named partition scheme of the service.
*/
@Fluent
public final class NamedPartitionScheme extends Partition {
/*
* Specifies how the service is partitioned.
*/
private PartitionScheme partitionScheme = PartitionScheme.NAMED;
/*
* Array for the names of the partitions.
*/
private List names;
/**
* Creates an instance of NamedPartitionScheme class.
*/
public NamedPartitionScheme() {
}
/**
* Get the partitionScheme property: Specifies how the service is partitioned.
*
* @return the partitionScheme value.
*/
@Override
public PartitionScheme partitionScheme() {
return this.partitionScheme;
}
/**
* Get the names property: Array for the names of the partitions.
*
* @return the names value.
*/
public List names() {
return this.names;
}
/**
* Set the names property: Array for the names of the partitions.
*
* @param names the names value to set.
* @return the NamedPartitionScheme object itself.
*/
public NamedPartitionScheme withNames(List names) {
this.names = names;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
super.validate();
if (names() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException("Missing required property names in model NamedPartitionScheme"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(NamedPartitionScheme.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeArrayField("names", this.names, (writer, element) -> writer.writeString(element));
jsonWriter.writeStringField("partitionScheme",
this.partitionScheme == null ? null : this.partitionScheme.toString());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of NamedPartitionScheme from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of NamedPartitionScheme 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 NamedPartitionScheme.
*/
public static NamedPartitionScheme fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
NamedPartitionScheme deserializedNamedPartitionScheme = new NamedPartitionScheme();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("names".equals(fieldName)) {
List names = reader.readArray(reader1 -> reader1.getString());
deserializedNamedPartitionScheme.names = names;
} else if ("partitionScheme".equals(fieldName)) {
deserializedNamedPartitionScheme.partitionScheme = PartitionScheme.fromString(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedNamedPartitionScheme;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy