All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.playtika.testcontainers.aerospike.enterprise.ImageVersion Maven / Gradle / Ivy

The newest version!
package com.playtika.testcontainers.aerospike.enterprise;

import lombok.NonNull;

import java.util.Comparator;

record ImageVersion (int major, int minor) implements Comparable {

    static ImageVersion parse(String version) {
        String[] parts = version.split("\\.");
        if (parts.length < 2) {
            throw new IllegalArgumentException("Invalid version: " + version);
        }
        try {
            int major = Integer.parseInt(parts[0]);
            int minor = Integer.parseInt(parts[1]);
            return new ImageVersion(major, minor);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Invalid version: " + version, e);
        }
    }

    @Override
    public int compareTo(@NonNull ImageVersion o) {
        return Comparator.comparingInt(ImageVersion::major)
                .thenComparingInt(ImageVersion::minor)
                .compare(this, o);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy