/*
 * Jellyfin API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 10.11.6
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

package org.openhab.binding.jellyfin.internal.gen;

import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "OpenAPI Generator")
public class Configuration {
    public static final String VERSION = "10.11.6";

    private static final AtomicReference<ApiClient> defaultApiClient = new AtomicReference<>();
    private static volatile Supplier<ApiClient> apiClientFactory = ApiClient::new;

    /**
     * Get the default API client, which would be used when creating API instances without providing an API client.
     *
     * @return Default API client
     */
    public static ApiClient getDefaultApiClient() {
        ApiClient client = defaultApiClient.get();
        if (client == null) {
            client = defaultApiClient.updateAndGet(val -> {
                if (val != null) { // changed by another thread
                    return val;
                }
                return apiClientFactory.get();
            });
        }
        return client;
    }

    /**
     * Set the default API client, which would be used when creating API instances without providing an API client.
     *
     * @param apiClient API client
     */
    public static void setDefaultApiClient(ApiClient apiClient) {
        defaultApiClient.set(apiClient);
    }

    /**
     * set the callback used to create new ApiClient objects
     */
    public static void setApiClientFactory(Supplier<ApiClient> factory) {
        apiClientFactory = Objects.requireNonNull(factory);
    }

    private Configuration() {
    }
}
