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.mynice.internal.xml.dto;
15 import java.util.List;
16 import java.util.stream.Stream;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
21 * This enum lists all handled T4 commands
23 * @author Gaƫl L'hopital - Initial contribution
26 public enum T4Command {
51 private int bitPosition;
53 private T4Command(int bitPosition) {
54 this.bitPosition = bitPosition;
57 public static T4Command fromCode(String commandCode) {
58 return Stream.of(T4Command.values()).filter(command -> command.name().equalsIgnoreCase(commandCode)).findFirst()
59 .orElseThrow(() -> new IllegalArgumentException("Unknown T4 command code (%s)".formatted(commandCode)));
62 public static List<T4Command> fromBitmask(int bitmask) {
63 return Stream.of(T4Command.values()).filter(command -> ((1 << command.bitPosition) & bitmask) != 0).toList();