Package io.microsphere.util
Class CharSequenceUtils
- java.lang.Object
-
- io.microsphere.util.CharSequenceUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isEmpty(java.lang.CharSequence value)
Checks if the providedCharSequence
is empty.static boolean
isNotEmpty(java.lang.CharSequence value)
Checks if the providedCharSequence
is not empty.static int
length(java.lang.CharSequence value)
Returns the length of the providedCharSequence
.
-
-
-
Method Detail
-
length
public static int length(java.lang.CharSequence value)
Returns the length of the providedCharSequence
.If the provided value is
null
, this method returns0
. Otherwise, it returns the result of calling theCharSequence.length()
method.Example Usage
length(null)
returns0
length("")
returns0
length("hello")
} returns5
- Parameters:
value
- theCharSequence
to get the length from- Returns:
- the length of the provided value, or
0
if it isnull
-
isEmpty
public static boolean isEmpty(java.lang.CharSequence value)
Checks if the providedCharSequence
is empty.A
CharSequence
is considered empty if its length is0
. This method returnstrue
if the provided value isnull
or has a length of0
.Example Usage
isEmpty(null)
returnstrue
isEmpty("")
returnstrue
isEmpty("hello")
} returnsfalse
- Parameters:
value
- theCharSequence
to check- Returns:
true
if the providedCharSequence
is empty or null, otherwisefalse
-
isNotEmpty
public static boolean isNotEmpty(java.lang.CharSequence value)
Checks if the providedCharSequence
is not empty.A
CharSequence
is considered not empty if its length is greater than0
. This method returnstrue
if the provided value is notnull
and has a length greater than0
.Example Usage
isNotEmpty(null)
returnsfalse
isNotEmpty("")
returnsfalse
isNotEmpty("hello")
} returnstrue
- Parameters:
value
- theCharSequence
to check- Returns:
true
if the providedCharSequence
is not empty, otherwisefalse
-
-