]> git.basschouten.com Git - openhab-addons.git/blob
a9c3ea1b52b6079e3b3cb067d5891f31c98bdfc1
[openhab-addons.git] /
1 /**
2  * Copyright 2017-2018 Gregory Moyer and contributors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.openhab.binding.lametrictime.api.model.enums;
17
18 import org.openhab.binding.lametrictime.api.model.ApiValue;
19
20 public enum Sound implements ApiValue
21 {
22     BICYCLE(SoundCategory.NOTIFICATIONS),
23     CAR(SoundCategory.NOTIFICATIONS),
24     CASH(SoundCategory.NOTIFICATIONS),
25     CAT(SoundCategory.NOTIFICATIONS),
26     DOG(SoundCategory.NOTIFICATIONS),
27     DOG2(SoundCategory.NOTIFICATIONS),
28     ENERGY(SoundCategory.NOTIFICATIONS),
29     KNOCK_KNOCK(SoundCategory.NOTIFICATIONS, "knock-knock"),
30     LETTER_EMAIL(SoundCategory.NOTIFICATIONS),
31     LOSE1(SoundCategory.NOTIFICATIONS),
32     LOSE2(SoundCategory.NOTIFICATIONS),
33     NEGATIVE1(SoundCategory.NOTIFICATIONS),
34     NEGATIVE2(SoundCategory.NOTIFICATIONS),
35     NEGATIVE3(SoundCategory.NOTIFICATIONS),
36     NEGATIVE4(SoundCategory.NOTIFICATIONS),
37     NEGATIVE5(SoundCategory.NOTIFICATIONS),
38     NOTIFICATION(SoundCategory.NOTIFICATIONS),
39     NOTIFICATION2(SoundCategory.NOTIFICATIONS),
40     NOTIFICATION3(SoundCategory.NOTIFICATIONS),
41     NOTIFICATION4(SoundCategory.NOTIFICATIONS),
42     OPEN_DOOR(SoundCategory.NOTIFICATIONS),
43     POSITIVE1(SoundCategory.NOTIFICATIONS),
44     POSITIVE2(SoundCategory.NOTIFICATIONS),
45     POSITIVE3(SoundCategory.NOTIFICATIONS),
46     POSITIVE4(SoundCategory.NOTIFICATIONS),
47     POSITIVE5(SoundCategory.NOTIFICATIONS),
48     POSITIVE6(SoundCategory.NOTIFICATIONS),
49     STATISTIC(SoundCategory.NOTIFICATIONS),
50     THUNDER(SoundCategory.NOTIFICATIONS),
51     WATER1(SoundCategory.NOTIFICATIONS),
52     WATER2(SoundCategory.NOTIFICATIONS),
53     WIN(SoundCategory.NOTIFICATIONS),
54     WIN2(SoundCategory.NOTIFICATIONS),
55     WIND(SoundCategory.NOTIFICATIONS),
56     WIND_SHORT(SoundCategory.NOTIFICATIONS),
57
58     ALARM1(SoundCategory.ALARMS),
59     ALARM2(SoundCategory.ALARMS),
60     ALARM3(SoundCategory.ALARMS),
61     ALARM4(SoundCategory.ALARMS),
62     ALARM5(SoundCategory.ALARMS),
63     ALARM6(SoundCategory.ALARMS),
64     ALARM7(SoundCategory.ALARMS),
65     ALARM8(SoundCategory.ALARMS),
66     ALARM9(SoundCategory.ALARMS),
67     ALARM10(SoundCategory.ALARMS),
68     ALARM11(SoundCategory.ALARMS),
69     ALARM12(SoundCategory.ALARMS),
70     ALARM13(SoundCategory.ALARMS);
71
72     private final SoundCategory category;
73     private final String rawValue;
74
75     private Sound(SoundCategory category)
76     {
77         this(category, null);
78     }
79
80     private Sound(SoundCategory category, String rawValue)
81     {
82         this.category = category;
83         this.rawValue = rawValue;
84     }
85
86     public SoundCategory getCategory()
87     {
88         return category;
89     }
90
91     @Override
92     public String toRaw()
93     {
94         return rawValue != null ? rawValue : name().toLowerCase();
95     }
96
97     public static Sound toEnum(String raw)
98     {
99         if (raw == null)
100         {
101             return null;
102         }
103
104         if (KNOCK_KNOCK.rawValue.equals(raw))
105         {
106             return KNOCK_KNOCK;
107         }
108
109         try
110         {
111             return valueOf(raw.toUpperCase());
112         }
113         catch (IllegalArgumentException e)
114         {
115             // not a valid raw string
116             return null;
117         }
118     }
119 }