Download benchmarks/java/SemVer.java from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/java/SemVer.java
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/java/SemVer.java
-
curl -L -o SemVer.java https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/java/SemVer.java
2.82 kB
| import java.util.Objects; | |
| /** | |
| * Anlamsal sürüm (MAJOR.MINOR.PATCH[-önsürüm]) ayrıştırma ve karşılaştırma. | |
| * Önsürümlü bir sürüm, aynı çekirdek sürümden önce gelir (1.0.0-rc.1 < 1.0.0). | |
| */ | |
| public final class SemVer implements Comparable<SemVer> { | |
| private final int major; | |
| private final int minor; | |
| private final int patch; | |
| private final String pre; | |
| public SemVer(int major, int minor, int patch, String pre) { | |
| if (major < 0 || minor < 0 || patch < 0) { | |
| throw new IllegalArgumentException("Sürüm numaraları negatif olamaz"); | |
| } | |
| this.major = major; | |
| this.minor = minor; | |
| this.patch = patch; | |
| this.pre = pre == null ? "" : pre; | |
| } | |
| public static SemVer parse(String text) { | |
| if (text == null || text.isBlank()) { | |
| throw new IllegalArgumentException("Boş sürüm"); | |
| } | |
| String core = text.trim(); | |
| String pre = ""; | |
| int dash = core.indexOf('-'); | |
| if (dash >= 0) { | |
| pre = core.substring(dash + 1); | |
| core = core.substring(0, dash); | |
| } | |
| String[] parts = core.split("\\."); | |
| if (parts.length != 3) { | |
| throw new IllegalArgumentException("MAJOR.MINOR.PATCH bekleniyor: " + text); | |
| } | |
| try { | |
| return new SemVer(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), | |
| Integer.parseInt(parts[2]), pre); | |
| } catch (NumberFormatException e) { | |
| throw new IllegalArgumentException("Sayısal olmayan bileşen: " + text); | |
| } | |
| } | |
| public SemVer bumpMajor() { | |
| return new SemVer(major + 1, 0, 0, ""); | |
| } | |
| public SemVer bumpMinor() { | |
| return new SemVer(major, minor + 1, 0, ""); | |
| } | |
| public SemVer bumpPatch() { | |
| return new SemVer(major, minor, patch + 1, ""); | |
| } | |
| public boolean isPreRelease() { | |
| return !pre.isEmpty(); | |
| } | |
| public int compareTo(SemVer o) { | |
| if (major != o.major) { | |
| return Integer.compare(major, o.major); | |
| } | |
| if (minor != o.minor) { | |
| return Integer.compare(minor, o.minor); | |
| } | |
| if (patch != o.patch) { | |
| return Integer.compare(patch, o.patch); | |
| } | |
| if (pre.isEmpty() || o.pre.isEmpty()) { | |
| return Boolean.compare(pre.isEmpty(), o.pre.isEmpty()); | |
| } | |
| return pre.compareTo(o.pre); | |
| } | |
| public boolean equals(Object x) { | |
| return x instanceof SemVer && compareTo((SemVer) x) == 0; | |
| } | |
| public int hashCode() { | |
| return Objects.hash(major, minor, patch, pre); | |
| } | |
| public String toString() { | |
| return major + "." + minor + "." + patch + (pre.isEmpty() ? "" : "-" + pre); | |
| } | |
| } | |