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

io.legaldocml.util.Strings Maven / Gradle / Ivy

The newest version!
package io.legaldocml.util;

/**
 * @author Jacques Militello
 */
public final class Strings {

	/**
	 * Empty String.
	 */
	public static final String EMPTY = "";

	/**
	 * 'null' String.
	 */
	public static final String NULL = "null";

	/**
	 * A String for a space character.
	 */
	public static final String SPACE = " ";

	/**
	 * Hide constructor.
	 */
	private Strings() {
	}

	/**
	 * 

* Checks if a CharSequence is whitespace, empty ("") or null. *

* *
	 * Strings.isBlank(null)      = true
	 * Strings.isBlank("")        = true
	 * Strings.isBlank(" ")       = true
	 * Strings.isBlank("jacques")     = false
	 * Strings.isBlank("  jacques  ") = false
	 * 
* * @param cs the CharSequence to check, may be null * @return {@code true} if the CharSequence is null, empty or whitespace */ public static boolean isBlank(CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } /** * Checks if a CharSequence is empty ("") or null. * *
	 * Strings.isEmpty(null)      = true
	 * Strings.isEmpty("")        = true
	 * Strings.isEmpty(" ")       = false
	 * Strings.isEmpty("jacques")     = false
	 * Strings.isEmpty("  jacques  ") = false
	 * 
* * @param cs the CharSequence to check, may be null. * @return {@code true} if the CharSequence is empty or null. */ public static boolean isEmpty(CharSequence cs) { return cs == null || cs.length() == 0; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy