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

dev.fitko.fitconnect.core.utils.Strings Maven / Gradle / Ivy

Go to download

Library that provides client access to the FIT-Connect api-endpoints for sending, subscribing and routing

The newest version!
package dev.fitko.fitconnect.core.utils;

public final class Strings {

    private Strings() {
    }

    /**
     * Tests a given string on null or empty
     *
     * @param s string to test
     * @return true if the string is null OR empty, false if both conditions do not apply
     */
    public static boolean isNullOrEmpty(final String s) {
        return s == null || s.isEmpty();
    }

    /**
     * Tests a given string on not null and not empty
     *
     * @param s string to test
     * @return true if the string is not null AND not empty, false if one dev.fitko.fitconnect.integrationtests.condition does not apply
     */
    public static boolean isNotNullOrEmpty(final String s) {
        return !isNullOrEmpty(s);
    }

    /**
     * Replace all non-printable control characters like \t, \r, \n and spaces from the given s.
     *
     * @param s string that should be cleaned
     * @return cleaned string without non-printable chars
     */
    public static String cleanNonPrintableChars(final String s) {
        return s.replaceAll("\n", "")
                .replaceAll("\r", "")
                .replaceAll("\t", "")
                .replaceAll(" ", "");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy