Class SqlFunctionRegistryFactory

java.lang.Object
org.litebridge.db.spi.impl.expression.SqlFunctionRegistryFactory

public class SqlFunctionRegistryFactory extends Object
Factory for creating SqlFunctionRegistry instances.

This is meant to be easily overridden by different database providers, replacing specific expressions with database-specific alternatives.

  • Field Details

    • labelGenerator

      protected final LabelGenerator labelGenerator
      Alias/identifier SQL fragment generator
    • selectSqlGenerator

      protected final SelectSqlGenerator selectSqlGenerator
      The select SQL generator.
  • Constructor Details

    • SqlFunctionRegistryFactory

      public SqlFunctionRegistryFactory(LabelGenerator labelGenerator, SelectSqlGenerator selectSqlGenerator)
      Constructs a new SqlFunctionRegistryFactory.
      Parameters:
      labelGenerator - The database provider's column alias/identifier SQL fragment generator
      selectSqlGenerator - The database provider's select SQL generator
  • Method Details

    • create

      public SqlFunctionRegistry create()
      Creates a SQL function registry for this database provider.
      Returns:
      SQL function registry for the database provider
    • createSelectColumn

      protected SelectColumn createSelectColumn(Column column, @Nullable String alias, @Nullable String tableAlias)
      Creates an expression to select a specific column.
      Parameters:
      column - Target column
      alias - Optional column alias
      Returns:
      Expression to select a specific column
    • createSubselect

      protected SubselectExpression createSubselect(Select subselect)
      Creates a subselect expression.
      Parameters:
      subselect - the select operation
      Returns:
      the subselect expression
    • createLiteral

      protected LiteralExpressionImpl createLiteral(@Nullable Object value, @Nullable String alias)
      Creates a literal expression.
      Parameters:
      value - the literal value
      Returns:
      the literal expression
    • createBindValue

      protected BindValueExpressionImpl createBindValue(int index, int size, ColumnType columnType, @Nullable String alias)
      Creates a bind value expression.
      Parameters:
      index - Bind value index.
      size - Size of the bind value.
      alias - Alias for the bind value.
      Returns:
      The bind value expression.
    • createSelectReference

      protected ColumnReference createSelectReference(Column column, @Nullable String alias, @Nullable String tableAlias)
      Creates a select reference expression.
      Parameters:
      column - the column
      Returns:
      the select reference expression
    • createAliasReference

      protected AliasReference createAliasReference(String alias, @Nullable String tableAlias)
      Creates an alias reference expression.
      Parameters:
      alias - the column to reference
      tableAlias - the alias to select from
      Returns:
      the select reference expression
    • createAvg

      protected DelegateExpression createAvg(SelectExpression target, Object... args)
      Creates an AVG-implementing expression.
      Parameters:
      target - Target expression to encapsulate.
      args - Not used; empty array
      Returns:
      A AVG-implementing expression
    • createMin

      protected DelegateExpression createMin(SelectExpression target, Object... args)
      Creates an MIN-implementing expression.
      Parameters:
      target - Target expression to encapsulate.
      args - Not used; empty array
      Returns:
      A MIN-implementing expression
    • createMax

      protected DelegateExpression createMax(SelectExpression target, Object... args)
      Creates an MAX-implementing expression.
      Parameters:
      target - Target expression to encapsulate.
      args - Not used; empty array
      Returns:
      A MAX-implementing expression
    • createCount

      protected SelectExpression createCount()
      Creates a COUNT-implementing expression.
      Returns:
      A COUNT-implementing expression
    • createUpper

      protected DelegateExpression createUpper(SelectExpression delegate, Object... args)
      Creates an UPPER-implementing expression.
      Parameters:
      delegate - Target expression to encapsulate.
      args - Not used; empty array
      Returns:
      An UPPER-implementing expression
    • createLower

      protected DelegateExpression createLower(SelectExpression target, Object... args)
      Creates a LOWER-implementing expression.
      Parameters:
      target - Target expression to encapsulate.
      args - Not used; empty array
      Returns:
      A LOWER-implementing expression
    • createSubstring

      protected DelegateExpression createSubstring(SelectExpression target, Object... args)
      Creates a SUBSTRING-implementing expression.
      Parameters:
      target - Target expression to encapsulate.
      args - expression arguments; should be [int, Inteeger]
      Returns:
      SUBSTRING-implementing expression
    • createSubstring

      protected DelegateExpression createSubstring(SelectExpression target, int start, @Nullable Integer length, @Nullable String alias)
      Creates a SUBSTRING-implementing expression.
      Parameters:
      target - Target expression to encapsulate.
      start - Start index (first character is 1)
      length - Substring length; may be null
      Returns:
      SUBSTRING-implementing expression
    • createAbs

      protected DelegateExpression createAbs(SelectExpression target, Object... args)
      Creates an ABS-implementing expression.
      Parameters:
      target - Target expression to encapsulate.
      args - Not used; empty array
      Returns:
      An ABS-implementing expression
    • createCast

      protected DelegateExpression createCast(SelectExpression target, Object... args)
    • createCurrentTimestamp

      protected SelectExpression createCurrentTimestamp()
      Creates a CURRENT_TIMESTAMP-implementing expression.
      Returns:
      A CURRENT_TIMESTAMP-implementing expression