2 * Copyright (c) 2010-2024 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.tado.internal.builder;
15 import java.io.IOException;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.tado.internal.api.ApiException;
20 import org.openhab.binding.tado.internal.api.model.ZoneState;
21 import org.openhab.binding.tado.internal.handler.TadoZoneHandler;
24 * Wrapper for zone state to support lazy loading.
26 * @author Dennis Frommknecht - Initial contribution
29 public class ZoneStateProvider {
30 private final TadoZoneHandler zoneHandler;
31 private @Nullable ZoneState zoneState;
33 public ZoneStateProvider(TadoZoneHandler zoneHandler) {
34 this.zoneHandler = zoneHandler;
37 public synchronized ZoneState getZoneState() throws IOException, ApiException {
38 ZoneState zoneState = this.zoneState;
39 if (zoneState == null) {
40 zoneState = this.zoneState = zoneHandler.getZoneState();