2 * Copyright (c) 2010-2022 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.linuxinput.internal.evdev4j;
15 import java.util.Optional;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import jnr.constants.Constant;
22 * @author Thomas Weißschuh - Initial contribution
30 static <T extends Constant> int combineFlags(Class<T> klazz, T... flags) {
31 if (klazz == Constant.class) {
32 throw new IllegalArgumentException();
35 for (Constant c : flags) {
36 result |= c.intValue();
41 public static <T extends Constant> Optional<T> constantFromInt(T[] cs, int i) {
43 if (c.intValue() == i) {
44 return Optional.of(c);
47 return Optional.empty();