From f82d32ea8fc34dd8e7633365af224f36514d9ac5 Mon Sep 17 00:00:00 2001 From: "Josiah (Gaming32) Glosson" Date: Sun, 10 Apr 2022 13:48:27 -0500 Subject: [PATCH] Add hashCode, equals, and toString to SortInfo --- .../io/github/arrayv/sortdata/SortInfo.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/main/java/io/github/arrayv/sortdata/SortInfo.java b/src/main/java/io/github/arrayv/sortdata/SortInfo.java index 24ee2a8f..73bf0840 100644 --- a/src/main/java/io/github/arrayv/sortdata/SortInfo.java +++ b/src/main/java/io/github/arrayv/sortdata/SortInfo.java @@ -210,6 +210,94 @@ public static String[] getCategories(SortInfo[] sorts) { return resultArray; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (bogoSort ? 1231 : 1237); + result = prime * result + (bucketSort ? 1231 : 1237); + result = prime * result + ((category == null) ? 0 : category.hashCode()); + result = prime * result + (disabled ? 1231 : 1237); + result = prime * result + (fromExtra ? 1231 : 1237); + result = prime * result + id; + result = prime * result + ((listName == null) ? 0 : listName.hashCode()); + result = prime * result + (radixSort ? 1231 : 1237); + result = prime * result + ((runAllName == null) ? 0 : runAllName.hashCode()); + result = prime * result + ((runName == null) ? 0 : runName.hashCode()); + result = prime * result + (slowSort ? 1231 : 1237); + result = prime * result + unreasonableLimit; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof SortInfo)) { + return false; + } + SortInfo other = (SortInfo) obj; + if (bogoSort != other.bogoSort) { + return false; + } + if (bucketSort != other.bucketSort) { + return false; + } + if (category == null) { + if (other.category != null) { + return false; + } + } else if (!category.equals(other.category)) { + return false; + } + if (disabled != other.disabled) { + return false; + } + if (fromExtra != other.fromExtra) { + return false; + } + if (id != other.id) { + return false; + } + if (listName == null) { + if (other.listName != null) { + return false; + } + } else if (!listName.equals(other.listName)) { + return false; + } + if (radixSort != other.radixSort) { + return false; + } + if (runAllName == null) { + if (other.runAllName != null) { + return false; + } + } else if (!runAllName.equals(other.runAllName)) { + return false; + } + if (runName == null) { + if (other.runName != null) { + return false; + } + } else if (!runName.equals(other.runName)) { + return false; + } + if (slowSort != other.slowSort) { + return false; + } + if (unreasonableLimit != other.unreasonableLimit) { + return false; + } + return true; + } + + @Override + public String toString() { + return "SortInfo for " + runAllName; + } + public static Builder builder() { return new Builder(); }