record AppVersion(int major, int minor, int patch) implements Comparable<AppVersion> { public static AppVersion of(String version) { var array = Arrays.copyOf(Arrays.stream(version.split("\\.")).mapToInt(Integer::parseInt).toArray(), 3); return new AppVersion(array[0], array[1], array[2]); } public int compareTo(AppVersion other) { return Comparator.comparingInt(AppVersion::major) .thenComparingInt(AppVersion::minor) .thenComparingInt(AppVersion::patch) .compare(this, other); } public String toString() { return "%d.%d.%d".formatted(major, minor, patch); } }