com.azure.resourcemanager.servicelinker.models.SelfHostedServer 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.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* The service properties when target service type is SelfHostedServer.
*/
@Fluent
public final class SelfHostedServer extends TargetServiceBase {
/*
* The target service type.
*/
private TargetServiceType type = TargetServiceType.SELF_HOSTED_SERVER;
/*
* The endpoint of service.
*/
private String endpoint;
/**
* Creates an instance of SelfHostedServer class.
*/
public SelfHostedServer() {
}
/**
* Get the type property: The target service type.
*
* @return the type value.
*/
@Override
public TargetServiceType type() {
return this.type;
}
/**
* Get the endpoint property: The endpoint of service.
*
* @return the endpoint value.
*/
public String endpoint() {
return this.endpoint;
}
/**
* Set the endpoint property: The endpoint of service.
*
* @param endpoint the endpoint value to set.
* @return the SelfHostedServer object itself.
*/
public SelfHostedServer withEndpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString());
jsonWriter.writeStringField("endpoint", this.endpoint);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of SelfHostedServer from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of SelfHostedServer 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 SelfHostedServer.
*/
public static SelfHostedServer fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
SelfHostedServer deserializedSelfHostedServer = new SelfHostedServer();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("type".equals(fieldName)) {
deserializedSelfHostedServer.type = TargetServiceType.fromString(reader.getString());
} else if ("endpoint".equals(fieldName)) {
deserializedSelfHostedServer.endpoint = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedSelfHostedServer;
});
}
}