Skip to content

Commit

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

import com.google.common.base.Strings;
import com.google.common.collect.Ordering;
import org.gradle.util.internal.VersionNumber;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -64,11 +63,11 @@ 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, qualifier);
return new Version(major, minor, micro, patch, toLowerCase(qualifier));
}

public VersionNumber asBaseVersion() {
return new VersionNumber(this.major, this.minor, this.micro, this.patch, null);
public Version asBaseVersion() {
return new Version(this.major, this.minor, this.micro, this.patch, null);
}

@Override
Expand All @@ -82,7 +81,7 @@ public int compareTo(@NotNull Version other) {
} else {
return this.patch != other.patch ? this.patch - other.patch
: Ordering.natural().nullsLast()
.compare(this.toLowerCase(this.qualifier), this.toLowerCase(other.qualifier));
.compare(this.qualifier, other.qualifier);
}
}

Expand All @@ -95,7 +94,7 @@ public boolean equals(Object obj) {
} 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.toLowerCase(this.qualifier), this.toLowerCase(other.qualifier));
&& Objects.equals(this.qualifier, other.qualifier);
}
}

Expand All @@ -105,12 +104,12 @@ public int hashCode() {
result = 31 * result + this.minor;
result = 31 * result + this.micro;
result = 31 * result + this.patch;
result = 31 * result + this.toLowerCase(this.qualifier).hashCode();
result = 31 * result + Objects.hashCode(this.qualifier);
return result;
}

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

0 comments on commit d60c35a

Please sign in to comment.