]> git.basschouten.com Git - openhab-addons.git/blob
99a5e80ebcab821d7e9f768205e2db97f76cd13f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.lifx.internal.dto;
14
15 /**
16  * @author Wouter Born - Initial contribution
17  */
18 public enum ApplicationRequest {
19
20     /**
21      * Don't apply the requested changes until a message with APPLY or APPLY_ONLY is sent.
22      */
23     NO_APPLY(0x00),
24
25     /**
26      * Apply the changes immediately and apply any pending changes.
27      */
28     APPLY(0x01),
29
30     /**
31      * Ignore the requested changes in this message and only apply pending changes.
32      */
33     APPLY_ONLY(0x02);
34
35     private final int value;
36
37     private ApplicationRequest(int value) {
38         this.value = value;
39     }
40
41     /**
42      * Gets the integer value of this application request.
43      *
44      * @return the integer value
45      */
46     public int getValue() {
47         return value;
48     }
49
50     /**
51      * Returns the {@link ApplicationRequest} for the given integer value.
52      *
53      * @param value the integer value
54      * @return the {@link ApplicationRequest} or <code>null</code>, if no {@link ApplicationRequest} exists for the
55      *         given value
56      */
57     public static ApplicationRequest fromValue(int value) {
58         for (ApplicationRequest ar : values()) {
59             if (ar.getValue() == value) {
60                 return ar;
61             }
62         }
63
64         return null;
65     }
66 }