]> git.basschouten.com Git - openhab-addons.git/blob
7ab06791af3cd29f0aa74cd9c6ebb67c1afccb7f
[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.exceptions.DTOPresentButEmptyException;
20
21 /**
22  * DTO for 'on' state of a light.
23  *
24  * @author Andrew Fiddian-Green - Initial contribution
25  */
26 @NonNullByDefault
27 public class OnState {
28     private @Nullable Boolean on;
29
30     /**
31      * @throws DTOPresentButEmptyException to indicate that the DTO is present but empty.
32      */
33     public boolean isOn() throws DTOPresentButEmptyException {
34         Boolean on = this.on;
35         if (Objects.nonNull(on)) {
36             return on;
37         }
38         throw new DTOPresentButEmptyException("'on' DTO is present but empty");
39     }
40
41     public void setOn(boolean on) {
42         this.on = on;
43     }
44 }