Package io.deephaven.base.string.cache
Class CharSequenceUtils
java.lang.Object
io.deephaven.base.string.cache.CharSequenceUtils
Static helpers for hashCode, equality, and comparison of CharSequences.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator<CharSequence>
A re-usable case-insensitive Comparator for CharSequences.static final Comparator<CharSequence>
A re-usable case-sensitive Comparator for CharSequences. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
caseInsensitiveHashCode
(@NotNull CharSequence charSequence) Calculate the hash code of a CharSequence as if it were an uppercase String.static boolean
contentEquals
(@NotNull CharSequence cs1, @NotNull CharSequence cs2) Compare two CharSequences for equality, disregarding class.static boolean
contentEqualsIgnoreCase
(@NotNull CharSequence cs1, @NotNull CharSequence cs2) Compare two CharSequences for case-insensitive equality, disregarding class.static int
hashCode
(@NotNull CharSequence charSequence) Calculate the hash code of a CharSequence as if it were a String.static boolean
nullSafeContentEquals
(@Nullable CharSequence cs1, @Nullable CharSequence cs2) Compare two CharSequences for equality, disregarding class and allowing for nullity.static boolean
nullSafeContentEqualsIgnoreCase
(@Nullable CharSequence cs1, @Nullable CharSequence cs2) Compare two CharSequences for case-insensitive equality, disregarding class and allowing for nullity.static boolean
regionMatches
(boolean ignoreCase, CharSequence cs1, int cs1Offset, CharSequence cs2, int cs2Offset, int length) Test content equality for two CharSequence sub-regions.
-
Field Details
-
CASE_SENSITIVE_COMPARATOR
A re-usable case-sensitive Comparator for CharSequences. -
CASE_INSENSITIVE_COMPARATOR
A re-usable case-insensitive Comparator for CharSequences.
-
-
Constructor Details
-
CharSequenceUtils
public CharSequenceUtils()
-
-
Method Details
-
hashCode
Calculate the hash code of a CharSequence as if it were a String.- Parameters:
charSequence
- The CharSequence- Returns:
- A hash code for the specified CharSequence.
-
caseInsensitiveHashCode
Calculate the hash code of a CharSequence as if it were an uppercase String.- Parameters:
charSequence
- The CharSequence- Returns:
- A hash code for the specified CharSequence.
-
contentEquals
public static boolean contentEquals(@NotNull @NotNull CharSequence cs1, @NotNull @NotNull CharSequence cs2) Compare two CharSequences for equality, disregarding class.- Parameters:
cs1
- The first CharSequencecs2
- The second CharSequence- Returns:
- Whether the supplied CharSequences represent an equal sequence of chars.
-
nullSafeContentEquals
public static boolean nullSafeContentEquals(@Nullable @Nullable CharSequence cs1, @Nullable @Nullable CharSequence cs2) Compare two CharSequences for equality, disregarding class and allowing for nullity.- Parameters:
cs1
- The first CharSequencecs2
- The second CharSequence- Returns:
- Whether the supplied CharSequences represent an equal sequence of chars.
-
contentEqualsIgnoreCase
public static boolean contentEqualsIgnoreCase(@NotNull @NotNull CharSequence cs1, @NotNull @NotNull CharSequence cs2) Compare two CharSequences for case-insensitive equality, disregarding class.- Parameters:
cs1
- The first CharSequencecs2
- The second CharSequence- Returns:
- Whether the supplied CharSequences represent an equal sequence of chars, disregarding case.
-
nullSafeContentEqualsIgnoreCase
public static boolean nullSafeContentEqualsIgnoreCase(@Nullable @Nullable CharSequence cs1, @Nullable @Nullable CharSequence cs2) Compare two CharSequences for case-insensitive equality, disregarding class and allowing for nullity.- Parameters:
cs1
- The first CharSequencecs2
- The second CharSequence- Returns:
- Whether the supplied CharSequences represent an equal sequence of chars.
-
regionMatches
public static boolean regionMatches(boolean ignoreCase, CharSequence cs1, int cs1Offset, CharSequence cs2, int cs2Offset, int length) Test content equality for two CharSequence sub-regions. See String.regionMatches(...).- Parameters:
ignoreCase
- Whether to use a case-insensitive comparisoncs1
- The first CharSequencecs1Offset
- The offset into the first CharSequencecs2
- The second CharSequencecs2Offset
- The offset into the second CharSequencelength
- The number of characters to compare- Returns:
- Whether the regions match
-