Class Name

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

    public final class Name
    extends java.lang.Object
    implements java.lang.Comparable<Name>
    A name.
    • Constructor Summary

      Constructors 
      Constructor Description
      Name​(java.lang.String unescapedName)
      Constructs a properly escaped SQL name.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Name other)
      Compares this name with the specified name for order.
      boolean equals​(java.lang.Object that)
      Checks two names for equality.
      java.lang.String getUnescaped()
      Returns the original unescaped name.
      int hashCode()
      Computes a hash code.
      java.lang.String toString()
      Gets a correctly escaped string representation of this name, which can be used in a SQL query to refer to the named entity.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Name

        public Name​(java.lang.String unescapedName)
        Constructs a properly escaped SQL name.

        The name will be equivalent to calling Sql::escapeName().

        Parameters:
        unescapedName - An unescaped name.
    • Method Detail

      • toString

        public java.lang.String toString()
        Gets a correctly escaped string representation of this name, which can be used in a SQL query to refer to the named entity.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The escaped name.
      • getUnescaped

        public java.lang.String getUnescaped()
        Returns the original unescaped name.

        Don't use the result of this method in SQL, as it is prone to SQL injection. The method should be used for use-cases where the original name is more readable (e.g., logging).

        Returns:
        The original unescaped name; or empty if the name was created with `createUnescaped`.
      • equals

        public boolean equals​(java.lang.Object that)
        Checks two names for equality.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        that - The other name.
        Returns:
        Whether the two names are equal.
      • compareTo

        public int compareTo​(Name other)
        Compares this name with the specified name for order.
        Specified by:
        compareTo in interface java.lang.Comparable<Name>
        Parameters:
        other - The other name.
        Returns:
        A negative integer, zero, or a positive integer as this name is less than, equal to, or greater than the other name.
      • hashCode

        public int hashCode()
        Computes a hash code.
        Overrides:
        hashCode in class java.lang.Object