com.azure.resourcemanager.automation.models.ContentSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-automation Show documentation
Show all versions of azure-resourcemanager-automation Show documentation
This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.automation.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;
/**
* Definition of the content source.
*/
@Fluent
public final class ContentSource implements JsonSerializable {
/*
* Gets or sets the hash.
*/
private ContentHash hash;
/*
* Gets or sets the content source type.
*/
private ContentSourceType type;
/*
* Gets or sets the value of the content. This is based on the content source type.
*/
private String value;
/*
* Gets or sets the version of the content.
*/
private String version;
/**
* Creates an instance of ContentSource class.
*/
public ContentSource() {
}
/**
* Get the hash property: Gets or sets the hash.
*
* @return the hash value.
*/
public ContentHash hash() {
return this.hash;
}
/**
* Set the hash property: Gets or sets the hash.
*
* @param hash the hash value to set.
* @return the ContentSource object itself.
*/
public ContentSource withHash(ContentHash hash) {
this.hash = hash;
return this;
}
/**
* Get the type property: Gets or sets the content source type.
*
* @return the type value.
*/
public ContentSourceType type() {
return this.type;
}
/**
* Set the type property: Gets or sets the content source type.
*
* @param type the type value to set.
* @return the ContentSource object itself.
*/
public ContentSource withType(ContentSourceType type) {
this.type = type;
return this;
}
/**
* Get the value property: Gets or sets the value of the content. This is based on the content source type.
*
* @return the value value.
*/
public String value() {
return this.value;
}
/**
* Set the value property: Gets or sets the value of the content. This is based on the content source type.
*
* @param value the value value to set.
* @return the ContentSource object itself.
*/
public ContentSource withValue(String value) {
this.value = value;
return this;
}
/**
* Get the version property: Gets or sets the version of the content.
*
* @return the version value.
*/
public String version() {
return this.version;
}
/**
* Set the version property: Gets or sets the version of the content.
*
* @param version the version value to set.
* @return the ContentSource object itself.
*/
public ContentSource withVersion(String version) {
this.version = version;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (hash() != null) {
hash().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("hash", this.hash);
jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString());
jsonWriter.writeStringField("value", this.value);
jsonWriter.writeStringField("version", this.version);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ContentSource from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ContentSource 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 ContentSource.
*/
public static ContentSource fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ContentSource deserializedContentSource = new ContentSource();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("hash".equals(fieldName)) {
deserializedContentSource.hash = ContentHash.fromJson(reader);
} else if ("type".equals(fieldName)) {
deserializedContentSource.type = ContentSourceType.fromString(reader.getString());
} else if ("value".equals(fieldName)) {
deserializedContentSource.value = reader.getString();
} else if ("version".equals(fieldName)) {
deserializedContentSource.version = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedContentSource;
});
}
}