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

io.apicurio.registry.utils.StringUtil Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
package io.apicurio.registry.utils;

public class StringUtil {

    public static boolean isEmpty(String string) {
        return string == null || string.isEmpty();
    }

    public static String limitStr(String value, int limit) {
        return limitStr(value, limit, false);
    }

    public static String asLowerCase(String value) {
        if (value == null) {
            return null;
        }
        return value.toLowerCase();
    }

    public static String limitStr(String value, int limit, boolean withEllipsis) {
        if (StringUtil.isEmpty(value)) {
            return value;
        }

        if (value.length() > limit) {
            if (withEllipsis) {
                return value.substring(0, limit - 3).concat("...");
            } else {
                return value.substring(0, limit);
            }
        } else {
            return value;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy