2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lametrictime.internal.api.common.impl;
15 import javax.ws.rs.client.Client;
16 import javax.ws.rs.client.ClientBuilder;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
21 import com.google.gson.Gson;
24 * Abstract class for clients.
26 * @author Gregory Moyer - Initial contribution
29 public abstract class AbstractClient {
30 protected final ClientBuilder clientBuilder;
33 private volatile Client client;
35 private volatile Gson gson;
37 public AbstractClient() {
38 this(ClientBuilder.newBuilder());
41 public AbstractClient(ClientBuilder clientBuilder) {
42 this.clientBuilder = clientBuilder;
45 protected @Nullable Client getClient() {
49 client = createClient();
57 protected @Nullable Gson getGson() {
69 protected abstract Client createClient();
71 protected Gson createGson() {
72 return GsonGenerator.create();
75 protected ClientBuilder getClientBuilder() {