2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.nanoleaf.internal.model;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * Represents panel layout of the light panels
21 * @author Martin Raepple - Initial contribution
24 public class PanelLayout {
26 private @Nullable Layout layout;
27 private @Nullable GlobalOrientation globalOrientation;
29 public PanelLayout() {
32 public PanelLayout(GlobalOrientation globalOrientation, Layout layout) {
33 this.globalOrientation = globalOrientation;
37 public @Nullable Layout getLayout() {
41 public void setLayout(Layout layout) {
45 public @Nullable GlobalOrientation getGlobalOrientation() {
46 return globalOrientation;
49 public void setGlobalOrientation(GlobalOrientation globalOrientation) {
50 this.globalOrientation = globalOrientation;
54 public boolean equals(@Nullable Object o) {
59 if (o == null || getClass() != o.getClass()) {
63 PanelLayout pl = (PanelLayout) o;
65 // For a panel layout to be equal to another panel layouit, all inner data structures must
66 // be equal, or they must be null both in this object or the object it is compared with.
68 GlobalOrientation go = globalOrientation;
69 GlobalOrientation otherGo = pl.getGlobalOrientation();
70 boolean goEquals = false;
71 if (go == null || otherGo == null) {
72 if (go == null && otherGo == null) {
73 // If one of the global oriantations are null, the other must also be null
74 // for them to be equal
78 goEquals = go.equals(otherGo);
82 // No reason to compare layout if global oriantation is different
87 Layout otherL = pl.getLayout();
89 if (l == null && otherL == null) {
93 if (l == null || otherL == null) {
97 return l.equals(otherL);
101 public int hashCode() {
102 final int prime = 31;
105 GlobalOrientation go = globalOrientation;
107 result = prime * result + go.hashCode();
112 result = prime * result + l.hashCode();