EventGridPublisherClientImplBuilder.java
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.messaging.eventgrid.implementation;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
/** A builder for creating a new instance of the EventGridPublisherClient type. */
@ServiceClientBuilder(serviceClients = {EventGridPublisherClientImpl.class})
public final class EventGridPublisherClientImplBuilder {
/*
* The HTTP pipeline to send requests through
*/
private HttpPipeline pipeline;
/**
* Sets The HTTP pipeline to send requests through.
*
* @param pipeline the pipeline value.
* @return the EventGridPublisherClientImplBuilder.
*/
public EventGridPublisherClientImplBuilder pipeline(HttpPipeline pipeline) {
this.pipeline = pipeline;
return this;
}
/*
* The serializer to serialize an object into a string
*/
private SerializerAdapter serializerAdapter;
/**
* Sets The serializer to serialize an object into a string.
*
* @param serializerAdapter the serializerAdapter value.
* @return the EventGridPublisherClientImplBuilder.
*/
public EventGridPublisherClientImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) {
this.serializerAdapter = serializerAdapter;
return this;
}
/**
* Builds an instance of EventGridPublisherClientImpl with the provided parameters.
*
* @return an instance of EventGridPublisherClientImpl.
*/
public EventGridPublisherClientImpl buildClient() {
if (pipeline == null) {
this.pipeline =
new HttpPipelineBuilder()
.policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
.build();
}
if (serializerAdapter == null) {
this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter();
}
EventGridPublisherClientImpl client = new EventGridPublisherClientImpl(pipeline, serializerAdapter);
return client;
}
}