Skip to content

Commit

Permalink
Add hashCode, equals, and toString to SortInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Apr 10, 2022
1 parent 57bb8e3 commit f82d32e
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions src/main/java/io/github/arrayv/sortdata/SortInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit f82d32e

Please sign in to comment.