Interface StringCompatible

All Superinterfaces:
CharSequence, Comparable<CharSequence>
All Known Subinterfaces:
StringAlike<TYPE>
All Known Implementing Classes:
AbstractCompressedString, ByteArrayCharSequenceAdapterImpl, ByteBufferCharSequenceAdapterImpl, ByteOrientedCharSequenceAdapter, CharSequenceAdapter, CharSequenceAdapterBuilder, CompressedString, MappedCompressedString

public interface StringCompatible extends CharSequence, Comparable<CharSequence>
Marker interface for CharSequences to be used in StringCache implementations.
  • Method Details

    • toString

      @NotNull @NotNull String toString()
      Convert this StringCompatible into a String. Implementations should not cache result Strings, in order to avoid inadvertently allowing promotion of short-lived objects under generational garbage collection.
      Specified by:
      toString in interface CharSequence
      Overrides:
      toString in class Object
      Returns:
      A newly constructed String representing the same sequence of characters as this StringCompatible.
    • toCompressedString

      @NotNull @NotNull CompressedString toCompressedString()
      Convert this StringCompatible into a CompressedString. Implementations should not cache result CompressedStrings, in order to avoid inadvertently allowing promotion of short-lived objects under generational garbage collection.
      Returns:
      A newly constructed CompressedString representing the same sequence of characters as this StringCompatible (or this object, if appropriate).
    • toMappedCompressedString

      @NotNull @NotNull MappedCompressedString toMappedCompressedString()
      Convert this StringCompatible into a MappedCompressedString. Implementations should not cache result CompressedStrings, in order to avoid inadvertently allowing promotion of short-lived objects under generational garbage collection.
      Returns:
      A newly constructed MappedCompressedString representing the same sequence of characters as this StringCompatible (or this object, if appropriate).
    • hashCode

      int hashCode()
      Implementations MUST match the current implementation of String.hashCode().
      Overrides:
      hashCode in class Object
      Returns:
      A hashcode value for this StringCompatible that matches the value a String of the same chars.
    • equals

      boolean equals(Object that)
      Overrides:
      equals in class Object
      Returns:
      true iff that is a StringCompatible of the same class with identical members.
    • compareTo

      int compareTo(@NotNull @NotNull CharSequence that)
      Implementations MUST compare StringCompatibles and Strings char-by-char.
      Specified by:
      compareTo in interface Comparable<CharSequence>
      Returns:
      0, <0, or >0 if that compares equal-to, less-than, or greater-than this.
    • hash

      static int hash(@Nullable @Nullable CharSequence cs)
      Compute a hash code for a CharSequence using the algorithm employed by String.hashCode().
      Parameters:
      cs - The CharSequence to hash
      Returns:
      The hash code