]> git.basschouten.com Git - openhab-addons.git/blob
8c6d429a095ab4c3e76c4759e1613918e69bae5a
[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.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     SPARKLE,
29     FIRE,
30     CANDLE,
31     // timed Effects
32     SUNRISE,
33     // applies to both
34     NO_EFFECT;
35
36     private static final Set<EffectType> FIXED = Set.of(SPARKLE, FIRE, CANDLE);
37     private static final Set<EffectType> TIMED = Set.of(SUNRISE);
38
39     public static EffectType of(@Nullable String value) {
40         if (value != null) {
41             try {
42                 return valueOf(value.toUpperCase());
43             } catch (IllegalArgumentException e) {
44                 // fall through
45             }
46         }
47         return NO_EFFECT;
48     }
49
50     public boolean isFixed() {
51         return FIXED.contains(this);
52     }
53
54     public boolean isTimed() {
55         return TIMED.contains(this);
56     }
57 }