StringUtil

Various String utility functions.

Most of the functions herein are re-implementations of the ones in Apache Commons StringUtils — kept in this codebase to avoid pulling in the full library.

Functions

Link copied to clipboard

Normalizes a path containing .., . and empty segments. X/foo/../Y becomes X/Y. Does not handle leading ...

Link copied to clipboard
fun defaultIfNull(text: String?, defaultValue: String = ""): String

Returns text, or defaultValue (default "") if text is null.

Link copied to clipboard
fun endsWithIgnoreCase(source: String, suffix: String): Boolean

Whether source ends with suffix, ignoring case.

Link copied to clipboard
fun equals(text1: String?, text2: String?): Boolean

Null-safe string equality.

Link copied to clipboard
fun hashCode(vararg values: String): Int
Link copied to clipboard
fun toString(vararg keyValues: Any?): String

Pretty toString printer.