diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-07-08 17:30:58 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-07-08 17:30:58 -0400 |
| commit | 9c681f38b742b26b841eb42bc19879cb90ac03de (patch) | |
| tree | 6c1b9eb1971629cc3c42bae3bff9fd930d4af11c /projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSError.java | |
| parent | 6d46c473d41c6c47e6b8bd8c676d925e544bd378 (diff) | |
Add XML property lists
Implement support for the XML property lists that are the newer version
of the ASCII ones. There are a few things that still need to be done,
but all of the basics are there
Next things
- Allow collapsing a property list into a series of objects
- Serialize both the property list and flattened objects to XML
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSError.java')
| -rw-r--r-- | projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSError.java | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSError.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSError.java new file mode 100644 index 0000000..9e46b5e --- /dev/null +++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSError.java @@ -0,0 +1,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); + } +} |
