Package io.deephaven.base.string.cache
Interface StringCompatible
- All Superinterfaces:
CharSequence
,Comparable<CharSequence>
- All Known Subinterfaces:
StringAlike<TYPE>
- All Known Implementing Classes:
AbstractCompressedString
,ByteArrayCharSequenceAdapterImpl
,ByteBufferCharSequenceAdapterImpl
,ByteOrientedCharSequenceAdapter
,CharSequenceAdapter
,CharSequenceAdapterBuilder
,CompressedString
,MappedCompressedString
Marker interface for CharSequences to be used in StringCache implementations.
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(@NotNull CharSequence that) Implementations MUST compare StringCompatibles and Strings char-by-char.boolean
static int
hash
(@Nullable CharSequence cs) Compute a hash code for a CharSequence using the algorithm employed by String.hashCode().int
hashCode()
Implementations MUST match the current implementation of String.hashCode().@NotNull CompressedString
Convert this StringCompatible into a CompressedString.@NotNull MappedCompressedString
Convert this StringCompatible into a MappedCompressedString.@NotNull String
toString()
Convert this StringCompatible into a String.Methods inherited from interface java.lang.CharSequence
charAt, chars, codePoints, isEmpty, length, subSequence
-
Method Details
-
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 interfaceCharSequence
- Overrides:
toString
in classObject
- Returns:
- A newly constructed String representing the same sequence of characters as this StringCompatible.
-
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
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(). -
equals
-
compareTo
Implementations MUST compare StringCompatibles and Strings char-by-char.- Specified by:
compareTo
in interfaceComparable<CharSequence>
- Returns:
- 0, <0, or >0 if that compares equal-to, less-than, or greater-than this.
-
hash
Compute a hash code for a CharSequence using the algorithm employed by String.hashCode().- Parameters:
cs
- The CharSequence to hash- Returns:
- The hash code
-