com.azure.resourcemanager.authorization.fluent.models.MicrosoftGraphPolicyBase 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.authorization.fluent.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.CoreUtils;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* policyBase
*
* Represents an Azure Active Directory object. The directoryObject type is the base type for many other directory
* entity types.
*/
@Fluent
public class MicrosoftGraphPolicyBase extends MicrosoftGraphDirectoryObjectInner {
/*
* Description for this policy.
*/
private String description;
/*
* Display name for this policy.
*/
private String displayName;
/*
* Represents an Azure Active Directory object. The directoryObject type is the base type for many other directory
* entity types.
*/
private Map additionalProperties;
/**
* Creates an instance of MicrosoftGraphPolicyBase class.
*/
public MicrosoftGraphPolicyBase() {
}
/**
* Get the description property: Description for this policy.
*
* @return the description value.
*/
public String description() {
return this.description;
}
/**
* Set the description property: Description for this policy.
*
* @param description the description value to set.
* @return the MicrosoftGraphPolicyBase object itself.
*/
public MicrosoftGraphPolicyBase withDescription(String description) {
this.description = description;
return this;
}
/**
* Get the displayName property: Display name for this policy.
*
* @return the displayName value.
*/
public String displayName() {
return this.displayName;
}
/**
* Set the displayName property: Display name for this policy.
*
* @param displayName the displayName value to set.
* @return the MicrosoftGraphPolicyBase object itself.
*/
public MicrosoftGraphPolicyBase withDisplayName(String displayName) {
this.displayName = displayName;
return this;
}
/**
* Get the additionalProperties property: Represents an Azure Active Directory object. The directoryObject type is
* the base type for many other directory entity types.
*
* @return the additionalProperties value.
*/
public Map additionalProperties() {
return this.additionalProperties;
}
/**
* Set the additionalProperties property: Represents an Azure Active Directory object. The directoryObject type is
* the base type for many other directory entity types.
*
* @param additionalProperties the additionalProperties value to set.
* @return the MicrosoftGraphPolicyBase object itself.
*/
public MicrosoftGraphPolicyBase withAdditionalProperties(Map additionalProperties) {
this.additionalProperties = additionalProperties;
return this;
}
/**
* {@inheritDoc}
*/
@Override
public MicrosoftGraphPolicyBase withDeletedDateTime(OffsetDateTime deletedDateTime) {
super.withDeletedDateTime(deletedDateTime);
return this;
}
/**
* {@inheritDoc}
*/
@Override
public MicrosoftGraphPolicyBase withId(String id) {
super.withId(id);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
super.validate();
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("id", id());
jsonWriter.writeStringField("deletedDateTime",
deletedDateTime() == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(deletedDateTime()));
jsonWriter.writeStringField("description", this.description);
jsonWriter.writeStringField("displayName", this.displayName);
if (additionalProperties != null) {
for (Map.Entry additionalProperty : additionalProperties.entrySet()) {
jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
}
}
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of MicrosoftGraphPolicyBase from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of MicrosoftGraphPolicyBase 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 MicrosoftGraphPolicyBase.
*/
public static MicrosoftGraphPolicyBase fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
MicrosoftGraphPolicyBase deserializedMicrosoftGraphPolicyBase = new MicrosoftGraphPolicyBase();
Map additionalProperties = null;
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("id".equals(fieldName)) {
deserializedMicrosoftGraphPolicyBase.withId(reader.getString());
} else if ("deletedDateTime".equals(fieldName)) {
deserializedMicrosoftGraphPolicyBase.withDeletedDateTime(reader
.getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())));
} else if ("description".equals(fieldName)) {
deserializedMicrosoftGraphPolicyBase.description = reader.getString();
} else if ("displayName".equals(fieldName)) {
deserializedMicrosoftGraphPolicyBase.displayName = reader.getString();
} else {
if (additionalProperties == null) {
additionalProperties = new LinkedHashMap<>();
}
additionalProperties.put(fieldName, reader.readUntyped());
}
}
deserializedMicrosoftGraphPolicyBase.additionalProperties = additionalProperties;
return deserializedMicrosoftGraphPolicyBase;
});
}
}