]> git.basschouten.com Git - openhab-addons.git/blob
a4c4f949f0079d04246db8078c8d77c0bf8a9e02
[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.lifx.internal.dto;
14
15 import java.util.Arrays;
16 import java.util.Optional;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * @author Wouter Born - Initial contribution
22  */
23 @NonNullByDefault
24 public enum LightLastHevCycleResult {
25
26     SUCCESS(0),
27     BUSY(1),
28     INTERRUPTED_BY_RESET(2),
29     INTERRUPTED_BY_HOMEKIT(3),
30     INTERRUPTED_BY_LAN(4),
31     INTERRUPTED_BY_CLOUD(5),
32     NONE(255);
33
34     private final int type;
35
36     LightLastHevCycleResult(int type) {
37         this.type = type;
38     }
39
40     public static LightLastHevCycleResult fromValue(int type) {
41         Optional<LightLastHevCycleResult> result = Arrays.stream(values()).filter((value) -> value.type == type)
42                 .findFirst();
43
44         if (!result.isPresent()) {
45             throw new IllegalArgumentException("Invalid LightLastHevCycleResult type: " + type);
46         }
47
48         return result.get();
49     }
50 }