View Javadoc
1   /*
2    * OpenFGA
3    * A high performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar.
4    *
5    * The version of the OpenAPI document: 1.x
6    * Contact: community@openfga.dev
7    *
8    * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9    * https://openapi-generator.tech
10   * Do not edit the class manually.
11   */
12  
13  
14  package org.apache.syncope.ext.openfga.client;
15  
16  import java.util.Objects;
17  import java.util.concurrent.atomic.AtomicReference;
18  import java.util.function.Supplier;
19  
20  @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.26.0")
21  public class Configuration {
22    public static final String VERSION = "1.x";
23  
24    private static final AtomicReference<ApiClient> defaultApiClient = new AtomicReference<>();
25    private static volatile Supplier<ApiClient> apiClientFactory = ApiClient::new;
26  
27    /**
28     * Get the default API client, which would be used when creating API instances without providing an API client.
29     *
30     * @return Default API client
31     */
32    public static ApiClient getDefaultApiClient() {
33      ApiClient client = defaultApiClient.get();
34      if (client == null) {
35        client = defaultApiClient.updateAndGet(val -> {
36          if (val != null) { // changed by another thread
37            return val;
38          }
39          return apiClientFactory.get();
40        });
41      }
42      return client;
43    }
44  
45    /**
46     * Set the default API client, which would be used when creating API instances without providing an API client.
47     *
48     * @param apiClient API client
49     */
50    public static void setDefaultApiClient(ApiClient apiClient) {
51      defaultApiClient.set(apiClient);
52    }
53  
54    /**
55     * set the callback used to create new ApiClient objects
56     */
57    public static void setApiClientFactory(Supplier<ApiClient> factory) {
58      apiClientFactory = Objects.requireNonNull(factory);
59    }
60  
61    private Configuration() {
62    }
63  }