]> git.basschouten.com Git - openhab-addons.git/blob
6d8b86bd9b279399545146f3e0d5ff220b98b217
[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 import java.util.stream.Collectors;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.hue.internal.dto.clip2.enums.ActionType;
22
23 import com.google.gson.annotations.SerializedName;
24
25 /**
26  * DTO for 'alert' of a light.
27  *
28  * @author Andrew Fiddian-Green - Initial contribution
29  */
30 @NonNullByDefault
31 public class Alerts {
32     private @Nullable @SerializedName("action_values") List<String> actionValues;
33     private @Nullable String action;
34
35     public @Nullable ActionType getAction() {
36         String action = this.action;
37         return Objects.nonNull(action) ? ActionType.of(action) : null;
38     }
39
40     public List<ActionType> getActionValues() {
41         List<String> actionValues = this.actionValues;
42         if (Objects.nonNull(actionValues)) {
43             return actionValues.stream().map(ActionType::of).collect(Collectors.toList());
44         }
45         return List.of();
46     }
47
48     public Alerts setAction(ActionType actionType) {
49         this.action = actionType.name().toLowerCase();
50         return this;
51     }
52 }