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.plugwise.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.plugwise.internal.listener.PlugwiseMessageListener;
18 import org.openhab.binding.plugwise.internal.protocol.Message;
19 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
22 * A filtered message listener listens to either all messages or only those of a device that has a certain MAC address.
24 * @author Wouter Born - Initial contribution
27 public class PlugwiseFilteredMessageListener {
29 private final PlugwiseMessageListener listener;
30 private final @Nullable MACAddress macAddress;
32 public PlugwiseFilteredMessageListener(PlugwiseMessageListener listener) {
36 public PlugwiseFilteredMessageListener(PlugwiseMessageListener listener, @Nullable MACAddress macAddress) {
37 this.listener = listener;
38 this.macAddress = macAddress;
41 public PlugwiseMessageListener getListener() {
45 public @Nullable MACAddress getMACAddress() {
49 public boolean matches(Message message) {
50 MACAddress localMACAddress = macAddress;
51 return localMACAddress == null || localMACAddress.equals(message.getMACAddress());