Interface StringReference

  • All Superinterfaces:
    java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>, Reference
    All Known Implementing Classes:
    BaseStringReference, BuilderStringReference, DexBackedStringReference, ImmutableStringReference

    public interface StringReference
    extends Reference, java.lang.CharSequence, java.lang.Comparable<java.lang.CharSequence>
    This class represents a reference to an arbitrary string. When possible, elsewhere in the interface, a string is represented directly by its value. A StringReference is only used in those cases where a generic Reference is needed This type also acts as a CharSequence wrapper around the referenced string value. As per the CharSequence contract, calling toString() on a StringReference yields the referenced string value. This is the same value returned by getString().
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int compareTo​(java.lang.CharSequence o)
      Compare this StringReference to another StringReference, or more generally to another CharSequence.
      boolean equals​(java.lang.Object o)
      Compares this StringReference to another CharSequence for equality.
      java.lang.String getString()
      Gets the referenced string.
      int hashCode()
      Returns a hashcode for this StringReference.
      • Methods inherited from interface java.lang.CharSequence

        charAt, chars, codePoints, length, subSequence, toString
    • Method Detail

      • getString

        @Nonnull
        java.lang.String getString()
        Gets the referenced string.
        Returns:
        the referenced string
      • hashCode

        int hashCode()
        Returns a hashcode for this StringReference. This is defined to be getString().hashCode().
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code value for this StringReference
      • equals

        boolean equals​(@Nullable
                       java.lang.Object o)
        Compares this StringReference to another CharSequence for equality. String StringReference is equal to a CharSequence iff this.getString().equals(other.toString()). Equivalently, This StringReference is equal to another StringReference iff this.getString().equals(other.getString()).
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - The object to be compared for equality with this TypeReference
        Returns:
        true if the specified object is equal to this TypeReference
      • compareTo

        int compareTo​(@Nonnull
                      java.lang.CharSequence o)
        Compare this StringReference to another StringReference, or more generally to another CharSequence. The comparison is defined to be this.getString().compareTo(other.toString()).
        Specified by:
        compareTo in interface java.lang.Comparable<java.lang.CharSequence>
        Parameters:
        o - The CharSequence to compare with this StringReference
        Returns:
        An integer representing the result of the comparison