]> git.basschouten.com Git - openhab-addons.git/blob
98b22c7f58368cc481c25e856bc175c8b12c503a
[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 Background.
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 Background {
29     BLACK(0x00),
30     BLUE(0x01),
31     LOGO(0x02),
32     UNKNOWN(0xFF);
33
34     private final int value;
35
36     Background(int value) {
37         this.value = value;
38     }
39
40     public static Background 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 }