Class CharSequenceUtils

  • All Implemented Interfaces:
    Utils

    public abstract class CharSequenceUtils
    extends java.lang.Object
    implements Utils
    The utilities class for CharSequence
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    CharSequence
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isEmpty​(java.lang.CharSequence value)
      Checks if the provided CharSequence is empty.
      static boolean isNotEmpty​(java.lang.CharSequence value)
      Checks if the provided CharSequence is not empty.
      static int length​(java.lang.CharSequence value)
      Returns the length of the provided CharSequence.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • length

        public static int length​(java.lang.CharSequence value)
        Returns the length of the provided CharSequence.

        If the provided value is null, this method returns 0. Otherwise, it returns the result of calling the CharSequence.length() method.

        Example Usage

        • length(null) returns 0
        • length("") returns 0
        • length("hello")} returns 5
        Parameters:
        value - the CharSequence to get the length from
        Returns:
        the length of the provided value, or 0 if it is null
      • isEmpty

        public static boolean isEmpty​(java.lang.CharSequence value)
        Checks if the provided CharSequence is empty.

        A CharSequence is considered empty if its length is 0. This method returns true if the provided value is null or has a length of 0.

        Example Usage

        • isEmpty(null) returns true
        • isEmpty("") returns true
        • isEmpty("hello")} returns false
        Parameters:
        value - the CharSequence to check
        Returns:
        true if the provided CharSequence is empty or null, otherwise false
      • isNotEmpty

        public static boolean isNotEmpty​(java.lang.CharSequence value)
        Checks if the provided CharSequence is not empty.

        A CharSequence is considered not empty if its length is greater than 0. This method returns true if the provided value is not null and has a length greater than 0.

        Example Usage

        • isNotEmpty(null) returns false
        • isNotEmpty("") returns false
        • isNotEmpty("hello")} returns true
        Parameters:
        value - the CharSequence to check
        Returns:
        true if the provided CharSequence is not empty, otherwise false