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

uk.autores.processors.Compare Maven / Gradle / Ivy

There is a newer version: 11.0.35-beta
Show newest version
// Copyright 2023 https://github.com/autores-uk/autores/blob/main/LICENSE.txt
// SPDX-License-Identifier: Apache-2.0
package uk.autores.processors;

/** Utility type for comparing certain types. */
final class Compare {

    private Compare() {}

    static > C max(C a, C b) {
        int n = a.compareTo(b);
        return n > 0 ? a : b;
    }

    static boolean sameSeq(CharSequence cs1, CharSequence cs2) {
        if (cs1.length() != cs2.length()) {
            return false;
        }
        for (int i = cs1.length() - 1; i >= 0; i--) {
            if (cs1.charAt(i) != cs2.charAt(i)) {
                return false;
            }
        }
        return true;
    }

    static boolean nullOrEmpty(CharSequence cs) {
        return cs == null || cs.length() == 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy