]> git.basschouten.com Git - openhab-addons.git/blob
21682998b1fb00401c4fc86715cdd4edd352be9b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.epsonprojector.internal.enums;
14
15 import java.util.Arrays;
16 import java.util.NoSuchElementException;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * Valid values for Gamma.
22  *
23  * @author Pauli Anttila - Initial contribution
24  * @author Yannick Schaus - Refactoring
25  * @author Michael Lobstein - Improvements for OH3
26  */
27 @NonNullByDefault
28 public enum Gamma {
29     G2_0(0x20),
30     G2_1(0x21),
31     G2_2(0x22),
32     G2_3(0x23),
33     G2_4(0x24),
34     CUSTOM(0xF0),
35     UNKNOWN(0xFF);
36
37     private final int value;
38
39     Gamma(int value) {
40         this.value = value;
41     }
42
43     public static Gamma forValue(int value) {
44         try {
45             return Arrays.stream(values()).filter(e -> e.value == value).findFirst().get();
46         } catch (NoSuchElementException e) {
47             return UNKNOWN;
48         }
49     }
50
51     public int toInt() {
52         return value;
53     }
54 }