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

devutility.internal.lang.StringHelper Maven / Gradle / Ivy

There is a newer version: 1.3.8.1
Show newest version
package devutility.internal.lang;

public class StringHelper {
	public static boolean isNullOrEmpty(String value) {
		return value == null || value.length() == 0 || value.trim().length() == 0;
	}

	public static boolean isNotEmpty(String value) {
		return !isNullOrEmpty(value);
	}

	public static String concat(String... str) {
		if (str.length == 0) {
			return null;
		}

		StringBuffer stringBuffer = new StringBuffer();

		for (int i = 0; i < str.length; i++) {
			stringBuffer.append(str[i]);
		}

		return stringBuffer.toString();
	}

	public static String upperFirstCase(String value) {
		char[] array = value.toCharArray();

		if (array[0] >= 'a' && array[0] <= 'z') {
			array[0] = (char) (array[0] - 32);
		}

		return String.valueOf(array);
	}

	public static String trimEnd(String value, String tail) {
		if (value == null || tail == null) {
			return value;
		}

		int index = value.indexOf(tail);

		if (index == value.length() - tail.length()) {
			return value.substring(0, index);
		}

		return value;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy