Class CharSequenceUtils

java.lang.Object
io.deephaven.base.string.cache.CharSequenceUtils

public class CharSequenceUtils extends Object
Static helpers for hashCode, equality, and comparison of CharSequences.
  • Field Details

    • CASE_SENSITIVE_COMPARATOR

      public static final Comparator<CharSequence> CASE_SENSITIVE_COMPARATOR
      A re-usable case-sensitive Comparator for CharSequences.
    • CASE_INSENSITIVE_COMPARATOR

      public static final Comparator<CharSequence> CASE_INSENSITIVE_COMPARATOR
      A re-usable case-insensitive Comparator for CharSequences.
  • Constructor Details

    • CharSequenceUtils

      public CharSequenceUtils()
  • Method Details

    • hashCode

      public static int hashCode(@NotNull @NotNull CharSequence charSequence)
      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

      public static int caseInsensitiveHashCode(@NotNull @NotNull CharSequence charSequence)
      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 CharSequence
      cs2 - 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 CharSequence
      cs2 - 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 CharSequence
      cs2 - 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 CharSequence
      cs2 - 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 comparison
      cs1 - The first CharSequence
      cs1Offset - The offset into the first CharSequence
      cs2 - The second CharSequence
      cs2Offset - The offset into the second CharSequence
      length - The number of characters to compare
      Returns:
      Whether the regions match