]> git.basschouten.com Git - openhab-addons.git/blob
89f00bf3fd008df4fed245a95a8f9017ca193bb3
[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.nest.internal.wwn.dto;
14
15 /**
16  * The data of WWN API errors.
17  *
18  * @author Wouter Born - Initial contribution
19  * @author Wouter Born - Improve exception handling
20  * @author Wouter Born - Add equals and hashCode methods
21  */
22 public class WWNErrorData {
23
24     private String error;
25     private String type;
26     private String message;
27     private String instance;
28
29     public String getError() {
30         return error;
31     }
32
33     public String getType() {
34         return type;
35     }
36
37     public String getMessage() {
38         return message;
39     }
40
41     public String getInstance() {
42         return instance;
43     }
44
45     @Override
46     public boolean equals(Object obj) {
47         if (this == obj) {
48             return true;
49         }
50         if (obj == null) {
51             return false;
52         }
53         if (getClass() != obj.getClass()) {
54             return false;
55         }
56         WWNErrorData other = (WWNErrorData) obj;
57         if (error == null) {
58             if (other.error != null) {
59                 return false;
60             }
61         } else if (!error.equals(other.error)) {
62             return false;
63         }
64         if (instance == null) {
65             if (other.instance != null) {
66                 return false;
67             }
68         } else if (!instance.equals(other.instance)) {
69             return false;
70         }
71         if (message == null) {
72             if (other.message != null) {
73                 return false;
74             }
75         } else if (!message.equals(other.message)) {
76             return false;
77         }
78         if (type == null) {
79             if (other.type != null) {
80                 return false;
81             }
82         } else if (!type.equals(other.type)) {
83             return false;
84         }
85         return true;
86     }
87
88     @Override
89     public int hashCode() {
90         final int prime = 31;
91         int result = 1;
92         result = prime * result + ((error == null) ? 0 : error.hashCode());
93         result = prime * result + ((instance == null) ? 0 : instance.hashCode());
94         result = prime * result + ((message == null) ? 0 : message.hashCode());
95         result = prime * result + ((type == null) ? 0 : type.hashCode());
96         return result;
97     }
98
99     @Override
100     public String toString() {
101         StringBuilder builder = new StringBuilder();
102         builder.append("ErrorData [error=").append(error).append(", type=").append(type).append(", message=")
103                 .append(message).append(", instance=").append(instance).append("]");
104         return builder.toString();
105     }
106 }