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