]> git.basschouten.com Git - openhab-addons.git/blob
8709122498204e326de96285839791d49934ace4
[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.api.dto.clip2.enums;
14
15 import java.util.Set;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * Enum for 'effect' types.
22  *
23  * @author Andrew Fiddian-Green - Initial contribution
24  */
25 @NonNullByDefault
26 public enum EffectType {
27     // fixed Effects
28     PRISM,
29     OPAL,
30     GLISTEN,
31     SPARKLE,
32     FIRE,
33     CANDLE,
34     // timed Effects
35     SUNRISE,
36     // applies to both
37     NO_EFFECT;
38
39     private static final Set<EffectType> FIXED = Set.of(PRISM, OPAL, GLISTEN, SPARKLE, FIRE, CANDLE);
40     private static final Set<EffectType> TIMED = Set.of(SUNRISE);
41
42     public static EffectType of(@Nullable String value) {
43         if (value != null) {
44             try {
45                 return valueOf(value.toUpperCase());
46             } catch (IllegalArgumentException e) {
47                 // fall through
48             }
49         }
50         return NO_EFFECT;
51     }
52
53     public boolean isFixed() {
54         return FIXED.contains(this);
55     }
56
57     public boolean isTimed() {
58         return TIMED.contains(this);
59     }
60 }