Class GlideString

  • All Implemented Interfaces:
    java.lang.Comparable<GlideString>

    public class GlideString
    extends java.lang.Object
    implements java.lang.Comparable<GlideString>
    Represents a Valkey string type. Since Valkey stores strings as byte[], such strings can contain non-UTF8 compatible symbols or even arbitrary binary data BLOBs.
    This class stores data byte[] too, but provides API to represent data as a String if conversion is possible.
    See Also:
    valkey.io for more details.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canConvertToString()
      Check whether stored data could be converted to a String.
      int compareTo​(GlideString o)
      Compare with another GlideString.
      GlideString concat​(GlideString other)
      Method to concatenate two GlideString objects
      boolean equals​(java.lang.Object o)  
      byte[] getBytes()
      Returns a copy of the underlying byte array to preserve immutability of the stored value.
      java.lang.String getString()
      Converts stored data to a human-friendly String if it is possible.
      static GlideString gs​(byte[] bytes)
      Create a GlideString using a byte array.
      static GlideString gs​(java.lang.String string)
      Create a GlideString using a String.
      int hashCode()  
      static GlideString of​(byte[] bytes)
      Create a GlideString using a byte array.
      static <ArgType> GlideString of​(ArgType o)
      Allow converting any type to GlideString
      static GlideString of​(java.lang.String string)
      Create a GlideString using a String.
      java.lang.String toString()
      Converts stored data to a human-friendly String if it is possible.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • of

        public static GlideString of​(java.lang.String string)
        Create a GlideString using a String.
      • of

        public static GlideString of​(byte[] bytes)
        Create a GlideString using a byte array.
      • of

        public static <ArgType> GlideString of​(ArgType o)
        Allow converting any type to GlideString
      • gs

        public static GlideString gs​(java.lang.String string)
        Create a GlideString using a String.
      • gs

        public static GlideString gs​(byte[] bytes)
        Create a GlideString using a byte array.
      • getBytes

        public byte[] getBytes()
        Returns a copy of the underlying byte array to preserve immutability of the stored value.
      • toString

        public java.lang.String toString()
        Converts stored data to a human-friendly String if it is possible.
        Overrides:
        toString in class java.lang.Object
      • getString

        public java.lang.String getString()
        Converts stored data to a human-friendly String if it is possible.
      • compareTo

        public int compareTo​(GlideString o)
        Compare with another GlideString.
        Specified by:
        compareTo in interface java.lang.Comparable<GlideString>
      • canConvertToString

        public boolean canConvertToString()
        Check whether stored data could be converted to a String.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object