]> git.basschouten.com Git - openhab-addons.git/blob
e54a380116d465c5c4870266f0e9c0cbfbd2c499
[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.hdpowerview.internal.dto;
14
15 import java.nio.charset.StandardCharsets;
16 import java.util.Base64;
17 import java.util.Objects;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21
22 /**
23  * State of a single Scene, as returned by an HD PowerView Hub
24  *
25  * @author Jacob Laursen - Initial contribution
26  */
27 @NonNullByDefault
28 public class Scene implements Comparable<Scene> {
29     public int id;
30     public @Nullable String name;
31     public int roomId;
32     public int order;
33     public int colorId;
34     public int iconId;
35
36     @Override
37     public boolean equals(@Nullable Object o) {
38         if (o == this) {
39             return true;
40         }
41         if (!(o instanceof Scene)) {
42             return false;
43         }
44         Scene other = (Scene) o;
45
46         return this.id == other.id && Objects.equals(name, other.name) && this.roomId == other.roomId
47                 && this.order == other.order && this.colorId == other.colorId && this.iconId == other.iconId;
48     }
49
50     @Override
51     public final int hashCode() {
52         final int prime = 31;
53         int result = 1;
54         String name = this.name;
55         result = prime * result + id;
56         result = prime * result + (name == null ? 0 : name.hashCode());
57         result = prime * result + roomId;
58         result = prime * result + order;
59         result = prime * result + colorId;
60         result = prime * result + iconId;
61
62         return result;
63     }
64
65     @Override
66     public int compareTo(Scene other) {
67         return Integer.compare(order, other.order);
68     }
69
70     public String getName() {
71         return new String(Base64.getDecoder().decode(name), StandardCharsets.UTF_8);
72     }
73 }