1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
package net.wotonomy.foundation;
import java.io.Serializable;
import java.util.Objects;
/**
* Represents an error code.
*
* @author bjculkin
*
*/
public class NSError implements Serializable {
private static final long serialVersionUID = 532874201592029465L;
public static final String NSWotonomyDomain = "wotonomy";
public static final String NSJavaDomain = "java";
public final String domain;
public final int error;
public final NSDictionary<String, Object> userInfo;
private String description;
private NSArray<NSError> underlyingErrors = new NSMutableArray<>();
@SuppressWarnings("unchecked")
public NSError(String domain, int error) {
this(domain, error, (NSDictionary<String, Object>) NSDictionary.EmptyDictionary);
}
public NSError(String domain, int error, NSDictionary<String, Object> userInfo) {
this.domain = domain;
this.error = error;
this.userInfo = userInfo;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public NSArray<NSError> getUnderlyingErrors() {
return underlyingErrors;
}
public void addUnderlyingError(NSError underlying) {
underlyingErrors.add(underlying);
}
@Override
public int hashCode() {
return Objects.hash(domain, error, userInfo, description);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
NSError other = (NSError) obj;
return Objects.equals(domain, other.domain) && error == other.error && Objects.equals(userInfo, other.userInfo)
&& Objects.equals(description, other.description);
}
}
|