]> git.basschouten.com Git - openhab-addons.git/blob
2804b1aa366be9f577fd7f4b7327a5c65cc87ed3
[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 Collection, as returned by an HD PowerView Hub
24  *
25  * @author Jacob Laursen - Initial contribution
26  */
27 @NonNullByDefault
28 public class SceneCollection implements Comparable<SceneCollection> {
29     public int id;
30     public @Nullable String name;
31     public int order;
32     public int colorId;
33     public int iconId;
34
35     @Override
36     public boolean equals(@Nullable Object o) {
37         if (o == this) {
38             return true;
39         }
40         if (!(o instanceof SceneCollection)) {
41             return false;
42         }
43         SceneCollection other = (SceneCollection) o;
44
45         return this.id == other.id && Objects.equals(name, other.name) && this.order == other.order
46                 && this.colorId == other.colorId && this.iconId == other.iconId;
47     }
48
49     @Override
50     public final int hashCode() {
51         final int prime = 31;
52         int result = 1;
53         String name = this.name;
54         result = prime * result + id;
55         result = prime * result + (name == null ? 0 : name.hashCode());
56         result = prime * result + order;
57         result = prime * result + colorId;
58         result = prime * result + iconId;
59
60         return result;
61     }
62
63     @Override
64     public int compareTo(SceneCollection other) {
65         return Integer.compare(order, other.order);
66     }
67
68     public String getName() {
69         return new String(Base64.getDecoder().decode(name), StandardCharsets.UTF_8);
70     }
71 }