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.teleinfo.internal.handler;
15 import java.util.Collection;
17 import java.util.concurrent.CopyOnWriteArraySet;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.binding.teleinfo.internal.TeleinfoDiscoveryService;
21 import org.openhab.binding.teleinfo.internal.data.Frame;
22 import org.openhab.core.thing.Bridge;
23 import org.openhab.core.thing.binding.BaseBridgeHandler;
24 import org.openhab.core.thing.binding.ThingHandlerService;
27 * The {@link TeleinfoAbstractControllerHandler} class defines a skeleton for controller handlers.
29 * @author Nicolas SIBERIL - Initial contribution
32 public abstract class TeleinfoAbstractControllerHandler extends BaseBridgeHandler {
34 private Set<TeleinfoControllerHandlerListener> listeners = new CopyOnWriteArraySet<>();
36 protected TeleinfoAbstractControllerHandler(Bridge bridge) {
40 public void addListener(final TeleinfoControllerHandlerListener listener) {
41 listeners.add(listener);
44 public void removeListener(final TeleinfoControllerHandlerListener listener) {
45 listeners.remove(listener);
48 protected void fireOnFrameReceivedEvent(final Frame frame) {
49 listeners.forEach(l -> l.onFrameReceived(frame));
53 public Collection<Class<? extends ThingHandlerService>> getServices() {
54 return Set.of(TeleinfoDiscoveryService.class);