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;
16 import java.util.Collections;
18 import java.util.concurrent.CopyOnWriteArraySet;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.teleinfo.internal.TeleinfoDiscoveryService;
22 import org.openhab.binding.teleinfo.internal.data.Frame;
23 import org.openhab.core.thing.Bridge;
24 import org.openhab.core.thing.binding.BaseBridgeHandler;
25 import org.openhab.core.thing.binding.ThingHandlerService;
28 * The {@link TeleinfoAbstractControllerHandler} class defines a skeleton for controller handlers.
30 * @author Nicolas SIBERIL - Initial contribution
33 public abstract class TeleinfoAbstractControllerHandler extends BaseBridgeHandler {
35 private Set<TeleinfoControllerHandlerListener> listeners = new CopyOnWriteArraySet<>();
37 protected TeleinfoAbstractControllerHandler(Bridge bridge) {
41 public void addListener(final TeleinfoControllerHandlerListener listener) {
42 listeners.add(listener);
45 public void removeListener(final TeleinfoControllerHandlerListener listener) {
46 listeners.remove(listener);
49 protected void fireOnFrameReceivedEvent(final Frame frame) {
50 listeners.forEach(l -> l.onFrameReceived(frame));
54 public Collection<Class<? extends ThingHandlerService>> getServices() {
55 return Collections.singleton(TeleinfoDiscoveryService.class);