]> git.basschouten.com Git - openhab-addons.git/blob
c807017b89568a2c0e5dd61a0dfd212b58c62408
[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.lametrictime.internal.api.dto.enums;
14
15 import org.openhab.binding.lametrictime.internal.api.dto.ApiValue;
16
17 /**
18  * Enum for sound.
19  *
20  * @author Gregory Moyer - Initial contribution
21  */
22 public enum Sound implements ApiValue {
23     BICYCLE(SoundCategory.NOTIFICATIONS),
24     CAR(SoundCategory.NOTIFICATIONS),
25     CASH(SoundCategory.NOTIFICATIONS),
26     CAT(SoundCategory.NOTIFICATIONS),
27     DOG(SoundCategory.NOTIFICATIONS),
28     DOG2(SoundCategory.NOTIFICATIONS),
29     ENERGY(SoundCategory.NOTIFICATIONS),
30     KNOCK_KNOCK(SoundCategory.NOTIFICATIONS, "knock-knock"),
31     LETTER_EMAIL(SoundCategory.NOTIFICATIONS),
32     LOSE1(SoundCategory.NOTIFICATIONS),
33     LOSE2(SoundCategory.NOTIFICATIONS),
34     NEGATIVE1(SoundCategory.NOTIFICATIONS),
35     NEGATIVE2(SoundCategory.NOTIFICATIONS),
36     NEGATIVE3(SoundCategory.NOTIFICATIONS),
37     NEGATIVE4(SoundCategory.NOTIFICATIONS),
38     NEGATIVE5(SoundCategory.NOTIFICATIONS),
39     NOTIFICATION(SoundCategory.NOTIFICATIONS),
40     NOTIFICATION2(SoundCategory.NOTIFICATIONS),
41     NOTIFICATION3(SoundCategory.NOTIFICATIONS),
42     NOTIFICATION4(SoundCategory.NOTIFICATIONS),
43     OPEN_DOOR(SoundCategory.NOTIFICATIONS),
44     POSITIVE1(SoundCategory.NOTIFICATIONS),
45     POSITIVE2(SoundCategory.NOTIFICATIONS),
46     POSITIVE3(SoundCategory.NOTIFICATIONS),
47     POSITIVE4(SoundCategory.NOTIFICATIONS),
48     POSITIVE5(SoundCategory.NOTIFICATIONS),
49     POSITIVE6(SoundCategory.NOTIFICATIONS),
50     STATISTIC(SoundCategory.NOTIFICATIONS),
51     THUNDER(SoundCategory.NOTIFICATIONS),
52     WATER1(SoundCategory.NOTIFICATIONS),
53     WATER2(SoundCategory.NOTIFICATIONS),
54     WIN(SoundCategory.NOTIFICATIONS),
55     WIN2(SoundCategory.NOTIFICATIONS),
56     WIND(SoundCategory.NOTIFICATIONS),
57     WIND_SHORT(SoundCategory.NOTIFICATIONS),
58
59     ALARM1(SoundCategory.ALARMS),
60     ALARM2(SoundCategory.ALARMS),
61     ALARM3(SoundCategory.ALARMS),
62     ALARM4(SoundCategory.ALARMS),
63     ALARM5(SoundCategory.ALARMS),
64     ALARM6(SoundCategory.ALARMS),
65     ALARM7(SoundCategory.ALARMS),
66     ALARM8(SoundCategory.ALARMS),
67     ALARM9(SoundCategory.ALARMS),
68     ALARM10(SoundCategory.ALARMS),
69     ALARM11(SoundCategory.ALARMS),
70     ALARM12(SoundCategory.ALARMS),
71     ALARM13(SoundCategory.ALARMS);
72
73     private final SoundCategory category;
74     private final String rawValue;
75
76     private Sound(SoundCategory category) {
77         this(category, null);
78     }
79
80     private Sound(SoundCategory category, String rawValue) {
81         this.category = category;
82         this.rawValue = rawValue;
83     }
84
85     public SoundCategory getCategory() {
86         return category;
87     }
88
89     @Override
90     public String toRaw() {
91         return rawValue != null ? rawValue : name().toLowerCase();
92     }
93
94     public static Sound toEnum(String raw) {
95         if (raw == null) {
96             return null;
97         }
98
99         if (KNOCK_KNOCK.rawValue.equals(raw)) {
100             return KNOCK_KNOCK;
101         }
102
103         try {
104             return valueOf(raw.toUpperCase());
105         } catch (IllegalArgumentException e) {
106             // not a valid raw string
107             return null;
108         }
109     }
110 }