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.onewire.internal.owserver;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * The {@link OwserverPressureScale} provides the owserver protocol pressure scale flags
20 * @author Jan N. Klug - Initial contribution
24 public enum OwserverPressureScale {
32 private static final int CLEAR_MASK = 0x001C0000;
33 private final int flag;
35 OwserverPressureScale(int flag) {
40 * get numeric value of this flag
44 public int getValue() {
49 * set this flag in a set of given flags
51 * @param flags aggregated flags
52 * @return parameter with this flag set
54 public int setFlag(int flags) {
55 return (flags & ~CLEAR_MASK) | this.getValue();
59 * get the pressure scale flag from a given set of flags
61 * @param flags set of flags
62 * @return pressure scale flag
63 * @throws IllegalArgumentException
65 public static OwserverPressureScale getFlag(int flags) throws IllegalArgumentException {
66 for (OwserverPressureScale value : values()) {
67 if (value.getValue() == (flags & CLEAR_MASK)) {
71 throw new IllegalArgumentException("Pressure scale flag not found");