]> git.basschouten.com Git - openhab-addons.git/blob
7f8da6cc5acb73c56cbfc4b1e72cdf10835a78e6
[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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.hue.internal.dto.clip2.enums.ButtonEventType;
17 import org.openhab.core.library.types.StringType;
18 import org.openhab.core.types.State;
19
20 import com.google.gson.annotations.SerializedName;
21
22 /**
23  * DTO for CLIP 2 button state.
24  *
25  * @author Andrew Fiddian-Green - Initial contribution
26  */
27 @NonNullByDefault
28 public class Button {
29     private @NonNullByDefault({}) @SerializedName("last_event") String lastEvent;
30
31     /**
32      * @return the last button event as an enum.
33      * @throws IllegalArgumentException if lastEvent is bad.
34      */
35     public ButtonEventType getLastEvent() throws IllegalArgumentException {
36         return ButtonEventType.valueOf(lastEvent.toUpperCase());
37     }
38
39     public State getLastEventState() {
40         return new StringType(getLastEvent().name());
41     }
42 }