]> git.basschouten.com Git - openhab-addons.git/blob
d73020a5e02830126f29dafe217d459d887574a7
[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;
14
15 import java.util.List;
16 import java.util.Objects;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.hue.internal.dto.clip2.enums.EffectType;
21
22 import com.google.gson.annotations.SerializedName;
23
24 /**
25  * DTO for 'effects' of a light.
26  *
27  * @author Andrew Fiddian-Green - Initial contribution
28  */
29 @NonNullByDefault
30 public class Effects {
31     private @Nullable @SerializedName("effect_values") List<String> effectValues;
32     private @Nullable String effect;
33     private @Nullable @SerializedName("status_values") List<String> statusValues;
34     private @Nullable String status;
35
36     public boolean allows(EffectType effect) {
37         List<String> statusValues = this.statusValues;
38         return Objects.nonNull(statusValues) ? statusValues.contains(effect.name().toLowerCase()) : false;
39     }
40
41     public EffectType getEffect() {
42         String effect = this.effect;
43         return Objects.nonNull(effect) ? EffectType.of(effect) : EffectType.NO_EFFECT;
44     }
45
46     public EffectType getStatus() {
47         return Objects.nonNull(status) ? EffectType.of(status) : EffectType.NO_EFFECT;
48     }
49
50     public List<String> getStatusValues() {
51         List<String> statusValues = this.statusValues;
52         return Objects.nonNull(statusValues) ? statusValues : List.of();
53     }
54
55     public Effects setEffect(EffectType effectType) {
56         effect = effectType.name().toLowerCase();
57         return this;
58     }
59
60     public Effects setStatusValues(List<String> statusValues) {
61         this.statusValues = statusValues;
62         return this;
63     }
64 }