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

io.fabric8.kubernetes.api.model.HasMetadataComparator Maven / Gradle / Ivy

package io.fabric8.kubernetes.api.model;

import java.util.Comparator;

public class HasMetadataComparator implements Comparator {
    @Override
    public int compare(HasMetadata a, HasMetadata b) {
        if (a == null || b == null) {
            throw new NullPointerException("Cannot compare null HasMetadata objects");
        }
        if (a == b) {
            return 0;
        }

        if (a instanceof Service && !(b instanceof Service)) {
            return -1;
        }
        if (b instanceof Service && !(a instanceof Service)) {
            return 1;
        }
        int classCompare = a.getClass().getSimpleName().compareTo(b.getClass().getSimpleName());
        if (classCompare != 0) {
            return classCompare;
        }
        return a.getMetadata().getName().compareTo(b.getMetadata().getName());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy