Package cn.sliew.milky.common.util
Class StringUtils
- java.lang.Object
-
- cn.sliew.milky.common.util.StringUtils
-
public final class StringUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcamelToSplitName(String camelName, String split)static StringdefaultToString(Object obj)Convert the suppliedObjectto a defaultStringrepresentation using the following algorithm.static booleanisBlank(String str)Determine if the suppliedStringis blank (i.e.,nullor consisting only of whitespace characters).static booleanisNotBlank(String str)static StringnullSafeToString(Object obj)Convert the suppliedObjectto aStringusing the following algorithm.static booleansubstringMatch(CharSequence str, int index, CharSequence substring)Test whether the given string matches the given substring at the given index.
-
-
-
Method Detail
-
isBlank
public static boolean isBlank(String str)
Determine if the suppliedStringis blank (i.e.,nullor consisting only of whitespace characters).- Parameters:
str- the string to check; may benull- Returns:
trueif the string is blank- See Also:
isNotBlank(String)
-
isNotBlank
public static boolean isNotBlank(String str)
- Parameters:
str- the string to check; may benull- Returns:
trueif the string is not blank- See Also:
isBlank(String)
-
substringMatch
public static boolean substringMatch(CharSequence str, int index, CharSequence substring)
Test whether the given string matches the given substring at the given index.- Parameters:
str- the original string (or StringBuilder)index- the index in the original string to start matching againstsubstring- the substring to match at the given index
-
nullSafeToString
public static String nullSafeToString(Object obj)
Convert the suppliedObjectto aStringusing the following algorithm.- If the supplied object is
null, this method returns"null". - If the supplied object is a primitive array, the appropriate
Arrays#toString(...)variant will be used to convert it to a String. - If the supplied object is an object array,
Arrays#deepToString(Object[])will be used to convert it to a String. - Otherwise,
toString()will be invoked on the object. If the result is non-null, that result will be returned. If the result isnull,"null"will be returned. - If any of the above results in an exception, this method delegates to
defaultToString(Object)
- Parameters:
obj- the object to convert to a String; may benull- Returns:
- a String representation of the supplied object; never
null - See Also:
Arrays.deepToString(Object[]),ClassUtil.nullSafeToString(Class...)
- If the supplied object is
-
defaultToString
public static String defaultToString(Object obj)
Convert the suppliedObjectto a defaultStringrepresentation using the following algorithm.- If the supplied object is
null, this method returns"null". - Otherwise, the String returned by this method will be generated analogous
to the default implementation of
Object.toString()by using the supplied object's class name and hash code as follows:obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj))
- Parameters:
obj- the object to convert to a String; may benull- Returns:
- the default String representation of the supplied object; never
null - See Also:
nullSafeToString(Object),ClassUtil.nullSafeToString(Class...)
- If the supplied object is
-
-