Skip to content

Commit

Permalink
remove hashcode and equals
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Aug 12, 2024
1 parent d60c35a commit 3b449e6
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions src/main/java/net/fabricmc/loom/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

package net.fabricmc.loom.util;

import java.util.Objects;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -63,7 +63,7 @@ public static Version parse(String version, boolean withPatch) {
int patch = !Strings.isNullOrEmpty(matcher.group(4)) ? Integer.parseInt(matcher.group(4)) : 0;
String qualifier = matcher.group(5);

return new Version(major, minor, micro, patch, toLowerCase(qualifier));
return new Version(major, minor, micro, patch, qualifier == null ? null : qualifier.toLowerCase(Locale.ROOT));
}

public Version asBaseVersion() {
Expand All @@ -84,32 +84,4 @@ public int compareTo(@NotNull Version other) {
.compare(this.qualifier, other.qualifier);
}
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
} else if (obj == null || this.getClass() != obj.getClass()) {
return false;
} else {
Version other = (Version) obj;
return this.major == other.major && this.minor == other.minor && this.micro == other.micro && this.patch == other.patch
&& Objects.equals(this.qualifier, other.qualifier);
}
}

@Override
public int hashCode() {
int result = this.major;
result = 31 * result + this.minor;
result = 31 * result + this.micro;
result = 31 * result + this.patch;
result = 31 * result + Objects.hashCode(this.qualifier);
return result;
}

@Nullable
private static String toLowerCase(@Nullable String string) {
return string == null ? null : string.toLowerCase();
}
}

0 comments on commit 3b449e6

Please sign in to comment.