]> git.basschouten.com Git - openhab-addons.git/blob
e66b2afe295516e3e37f9f5b5ce348a8f38b3bd6
[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.hue.internal.dto.clip2.enums;
14
15 import java.util.EnumSet;
16 import java.util.Set;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * Enum for resource types.
23  *
24  * @author Andrew Fiddian-Green - Initial contribution
25  */
26 @NonNullByDefault
27 public enum ResourceType {
28     AUTH_V1,
29     BEHAVIOR_INSTANCE,
30     BEHAVIOR_SCRIPT,
31     BRIDGE,
32     BRIDGE_HOME,
33     BUTTON,
34     DEVICE,
35     DEVICE_POWER,
36     ENTERTAINMENT,
37     ENTERTAINMENT_CONFIGURATION,
38     GEOFENCE,
39     GEOFENCE_CLIENT,
40     GEOLOCATION,
41     GROUPED_LIGHT,
42     HOMEKIT,
43     LIGHT,
44     LIGHT_LEVEL,
45     MOTION,
46     PUBLIC_IMAGE,
47     ROOM,
48     RELATIVE_ROTARY,
49     SCENE,
50     TEMPERATURE,
51     ZGP_CONNECTIVITY,
52     ZIGBEE_CONNECTIVITY,
53     ZONE,
54     UPDATE,
55     ADD,
56     DELETE,
57     ERROR;
58
59     public static final Set<ResourceType> SSE_TYPES = EnumSet.of(UPDATE, ADD, DELETE, ERROR);
60
61     public static ResourceType of(@Nullable String value) {
62         if (value != null) {
63             try {
64                 return valueOf(value.toUpperCase());
65             } catch (IllegalArgumentException e) {
66                 // fall through
67             }
68         }
69         return ERROR;
70     }
71
72     @Override
73     public String toString() {
74         String s = this.name().replace("_", " ");
75         return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
76     }
77 }