Interface SqlIdentifier

All Superinterfaces:
Iterable<SqlIdentifier>, Streamable<SqlIdentifier>, Supplier<Stream<SqlIdentifier>>

public interface SqlIdentifier extends Streamable<SqlIdentifier>
Represents a named object that exists in the database like a table name or a column name. SQL identifiers are created from a name with specifying whether the name should be quoted or unquoted.

SqlIdentifier renders its name using IdentifierProcessing rules. Use getReference() to refer to an object using the identifier when e.g. obtaining values from a result or providing values for a prepared statement. toSql(IdentifierProcessing) renders the identifier for SQL statement usage.

SqlIdentifier objects are immutable. Calling transformational methods such as transform(UnaryOperator) creates a new instance.

SqlIdentifier are composable so an identifier may consist of a single identifier part or can be composed from multiple parts. Composed identifier can be traversed with Streamable.stream() or Iterable.iterator(). The iteration order depends on the actual composition ordering.

Since:
2.0
Author:
Jens Schauder, Mark Paluch, Kurt Niemi
  • Field Details

  • Method Details

    • getReference

      @Deprecated(since="3.1", forRemoval=true) String getReference(IdentifierProcessing processing)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 3.1, use the #getReference() method instead.
      Return the reference name after applying IdentifierProcessing rules. The reference name is used for programmatic access to the object identified by this SqlIdentifier.
      Parameters:
      processing - identifier processing rules.
      Returns:
    • getReference

      default String getReference()
      The reference name is used for programmatic access to the object identified by this SqlIdentifier. Use this method whenever accessing a column in a ResultSet and we do not want any quoting applied.
      Returns:
      the string representation of the identifier, which may be used to access columns in a ResultSet
      See Also:
    • toSql

      String toSql(IdentifierProcessing processing)
      Use this method when rendering an identifier in SQL statements as in:
       select yourColumn from someTable
       
      IdentifierProcessing rules are applied to the identifier.
      Parameters:
      processing - identifier processing rules.
      Returns:
    • transform

      SqlIdentifier transform(UnaryOperator<String> transformationFunction)
      Transform the SQL identifier name by applying a transformation function. The transformation function must return a valid, non-null identifier String.
      Parameters:
      transformationFunction - the transformation function. Must return a non-null identifier String.
      Returns:
      a new SqlIdentifier with the transformation applied.
    • quoted

      static SqlIdentifier quoted(String name)
      Create a new quoted identifier given name.
      Parameters:
      name - the identifier.
      Returns:
      a new quoted identifier given name.
    • unquoted

      static SqlIdentifier unquoted(String name)
      Create a new unquoted identifier given name.
      Parameters:
      name - the identifier.
      Returns:
      a new unquoted identifier given name.
    • from

      static SqlIdentifier from(SqlIdentifier... sqlIdentifiers)
      Create a new composite SqlIdentifier from one or more SqlIdentifiers.

      Composite identifiers do not allow transform(UnaryOperator) transformation.

      Parameters:
      sqlIdentifiers - the elements of the new identifier.
      Returns:
      the new composite identifier.