
com.azure.resourcemanager.orbital.models.ContactsPropertiesContactProfile 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.orbital.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;
/**
* The reference to the contact profile resource.
*/
@Fluent
public final class ContactsPropertiesContactProfile extends ResourceReference {
/**
* Creates an instance of ContactsPropertiesContactProfile class.
*/
public ContactsPropertiesContactProfile() {
}
/**
* {@inheritDoc}
*/
@Override
public ContactsPropertiesContactProfile withId(String id) {
super.withId(id);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
if (id() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property id in model ContactsPropertiesContactProfile"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(ContactsPropertiesContactProfile.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("id", id());
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ContactsPropertiesContactProfile from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ContactsPropertiesContactProfile 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 ContactsPropertiesContactProfile.
*/
public static ContactsPropertiesContactProfile fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ContactsPropertiesContactProfile deserializedContactsPropertiesContactProfile
= new ContactsPropertiesContactProfile();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("id".equals(fieldName)) {
deserializedContactsPropertiesContactProfile.withId(reader.getString());
} else {
reader.skipChildren();
}
}
return deserializedContactsPropertiesContactProfile;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy