]> git.basschouten.com Git - openhab-addons.git/blob
fbac46372a0814806f698c1172a7639d0f0543b3
[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 Luminance.
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 Luminance {
29     NORMAL(0x00),
30     ECO(0x01),
31     MEDIUM(0x02),
32     UNKNOWN(0xFF);
33
34     private final int value;
35
36     Luminance(int value) {
37         this.value = value;
38     }
39
40     public static Luminance forValue(int value) {
41         try {
42             return Arrays.stream(values()).filter(e -> e.value == value).findFirst().get();
43         } catch (NoSuchElementException e) {
44             return UNKNOWN;
45         }
46     }
47
48     public int toInt() {
49         return value;
50     }
51 }