java.lang.Object
org.litebridgedb.orm.expression.Fn

public final class Fn extends Object
Functions: Utility class that provides static methods for constructing query expressions.

This class is a collection of static functions to create different types of select expressions within a database query. This includes selecting DTO fields, database expressions, or counting rows in a query.

This class cannot be instantiated.

  • Method Details

    • f

      public static ExpressionSpec f(String field)
      Selects a DTO field by name for the DTO class selected in the query.

      Shorthand for field(String).

      Parameters:
      field - The name of the DTO field to select.
      Returns:
      a SelectFieldSpec expression instance to select the specified field.
    • f

      public static ExpressionSpec f(Class<?> dtoClass, String field)
      Selects a DTO field by name for the specified DTO type that is selected/joined in the query.

      Shorthand for field(Class, String).

      Parameters:
      field - The name of the DTO field to select.
      Returns:
      a SelectFieldSpec expression instance to select the specified field.
    • field

      public static ExpressionSpec field(String field)
      Selects a DTO field by name for the DTO class selected in the query.
      Parameters:
      field - The name of the DTO field to select.
      Returns:
      a SelectFieldSpec expression instance to select the specified field.
    • field

      public static ExpressionSpec field(Class<?> dtoClass, String field)
      Selects a DTO field by name for the specified DTO type that is selected/joined in the query.
      Parameters:
      field - The name of the DTO field to select.
      Returns:
      a SelectFieldSpec expression instance to select the specified field.
    • c

      public static ExpressionSpec c(String column)
      Selects a database column by name.

      This is shorthand for column(String).

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      column - The name of the column to select.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • column

      public static ExpressionSpec column(String column)
      Selects a database column by name.

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      column - The name of the column to select.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • c

      public static ExpressionSpec c(String table, String column)
      Selects a database column by name.

      Shorthand for column(String, String)

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • column

      public static ExpressionSpec column(String table, String column)
      Selects a database column by name.

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • c

      public static ExpressionSpec c(Table table, String column)
      Selects a database column by name.

      Shorthand for column(Table, String)

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • column

      public static ExpressionSpec column(Table table, String column)
      Selects a database column by name.

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • ca

      public static ExpressionSpec ca(Table table, String column, @Nullable String columnAlias)
      Selects a database column by name and alias.

      Shorthand for columnAlias(Table, String, String) (Table, String, String)}

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      columnAlias - The alias to use for the column; may be null.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • columnAlias

      public static ExpressionSpec columnAlias(Table table, String column, @Nullable String columnAlias)
      Selects a database column by name and alias.

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      columnAlias - The alias to use for the column; may be null.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • ca

      public static ExpressionSpec ca(String column, @Nullable String alias)
      Selects a database column by name and alias.

      Shorthand for columnAlias(String, String)

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      column - The name of the column to select.
      alias - The alias to use for the column.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • columnAlias

      public static ExpressionSpec columnAlias(String column, @Nullable String alias)
      Selects a database column by name and alias.

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      column - The name of the column to select.
      alias - The alias to use for the column.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • ca

      public static ExpressionSpec ca(String table, String column, @Nullable String columnAlias)
      Selects a database column by name and alias.

      Shorthand for columnAlias(Table, String, String)

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      columnAlias - The alias to use for the column.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • columnAlias

      public static ExpressionSpec columnAlias(String table, String column, @Nullable String columnAlias)
      Selects a database column by name and alias.

      The returned ProtoColumnExpressionSpec value has no context of the table it is selecting from yet.

      Parameters:
      table - The table to select the column from.
      column - The name of the column to select.
      columnAlias - The alias to use for the column.
      Returns:
      a ProtoColumnExpressionSpec expression instance to select a specific column.
    • convert

      public static <T> ConvertSpec<T> convert(ExpressionSpec expression, Class<T> returnType)
      Converts a database result into the specified Java type.

      This uses Litebridge's registered type converter to perform the conversion; it is not a database operation.

      It can be used to ensure that the return value of a nested expression is converted to the specified Java type on the ORM side; e.g. avg(ExpressionSpec) returns a @{Number} instance by default, with the actual return type being determined by the database. To convert the return type to a Long, convert() can be used to convert it before returning: litebridge.select(Fn.convert(Fn.avg(column), Long.class));

      Parameters:
      expression - The target expression result to convert
      returnType - The type to convert the expression result to
      Returns:
      a ProtoColumnExpressionSpec expression instance to convert the return value of the nested expression
    • convert

      public static <T> ConvertIntent<T> convert(Class<T> returnType, ExpressionSpec... expressions)
    • row

      public static ConvertIntent<Row> row(ExpressionSpec... expressions)
    • avg

      public static TypeOverrideExpressionSpec<Number> avg(String column)
      AVG(): Returns the average value of a column/field.
      Parameters:
      column - Name of the target column/field to calculate the average value of.
      Returns:
      a ProtoNestableTOExpr expression instance to select the average value of a column/field.
    • avg

      public static TypeOverrideExpressionSpec<Number> avg(ExpressionSpec expressionSpec)
      AVG(): Returns the average value of a column/field.
      Parameters:
      expressionSpec - Target nested expression to calculate the average value of.
      Returns:
      a ProtoNestableTOExpr expression instance to select the average value of a column/field.
    • max

      public static TypeOverrideExpressionSpec<Number> max(String column)
      MAX(): Returns the highest or largest value within a specified column/field.
      Parameters:
      column - Name of the target column/field to calculate the maximum value of.
      Returns:
      a ProtoNestableTOExpr expression instance to select the maximum value of a column/field.
    • max

      public static TypeOverrideExpressionSpec<Number> max(ExpressionSpec expressionSpec)
      MAX(): Returns the highest or largest value within a specified expression.
      Parameters:
      expressionSpec - Target nested expression to calculate the maximum value of.
      Returns:
      a ProtoNestableTOExpr expression instance to select the maximum value of a column/field.
    • min

      public static TypeOverrideExpressionSpec<Number> min(String column)
      MIN(): Returns the lowest or smallest value within a specified column or expression
      Parameters:
      column - Name of the target column/field to calculate the maximum value of.
      Returns:
      a ProtoNestableTOExpr expression instance to select the maximum value of a column/field.
    • min

      public static TypeOverrideExpressionSpec<Number> min(ExpressionSpec expressionSpec)
      MIN(): Returns the lowest or smallest value within a specified column or expression
      Parameters:
      expressionSpec - Target nested expression to calculate the maximum value of.
      Returns:
      a ProtoNestableTOExpr expression instance to select the maximum value of a column/field.
    • count

      public static TypeOverrideExpressionSpec<Long> count()
      COUNT(): Selects the count of rows matching the query.
      Returns:
      a CountSpec expression instance to select the count of rows.
    • upper

      public static ProtoNestableTOExpr<String> upper(String column)
      UPPER(): Returns the uppercase value of a column's text.
      Parameters:
      column - Target column/field name
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
    • upper

      public static ProtoNestableTOExpr<String> upper(ExpressionSpec expressionSpec)
      UPPER(): Returns the uppercase value of a column's text.
      Parameters:
      expressionSpec - Target nested expression
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
    • lower

      public static ProtoNestableTOExpr<String> lower(String column)
      LOWER(): Returns the lowercase value of a column's text.
      Parameters:
      column - Target column/field name
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
    • lower

      public static ProtoNestableTOExpr<String> lower(ExpressionSpec expressionSpec)
      LOWER(): Returns the lowercase value of a column's text.
      Parameters:
      expressionSpec - Target nested expression
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
    • substring

      public static ProtoNestableTOExpr<String> substring(String column, int start)
      SUBSTRING(): Returns the lowercase value of a column's text.

      This shorthand version omits the "length" parameter and thus extracts everything from the start position to the end of the text.

      Parameters:
      column - Target column to extract characters from.
      start - The starting position. The first character of a database string is always 1.
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
      See Also:
    • substring

      public static ProtoNestableTOExpr<String> substring(ExpressionSpec expressionSpec, int start)
      SUBSTRING(): Returns the lowercase value of a column's text.

      This shorthand version omits the "length" parameter and thus extracts everything from the start position to the end of the text.

      Parameters:
      expressionSpec - Target nested expression to extract characters from.
      start - The starting position. The first character of a database string is always 1.
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
      See Also:
    • substring

      public static ProtoNestableTOExpr<String> substring(String column, int start, int length)
      SUBSTRING(): Returns the lowercase value of a column's text.
      Parameters:
      column - Target column to extract characters from.
      start - The starting position. The first character of a database string is always 1.
      length - The number of characters to return.
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
      See Also:
    • substring

      public static ProtoNestableTOExpr<String> substring(ExpressionSpec expressionSpec, int start, int length)
      SUBSTRING(): Returns the lowercase value of a column's text.
      Parameters:
      expressionSpec - Target nested expression to extract characters from.
      start - The starting position. The first character of a database string is always 1.
      length - The number of characters to return.
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
      See Also:
    • abs

      public static ProtoNestableTOExpr<Number> abs(String column)
      ABS(): Absolute value of a number.
      Parameters:
      column - Target column/field.
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
    • abs

      public static ProtoNestableTOExpr<Number> abs(ExpressionSpec expressionSpec)
      ABS(): Absolute value of a number.
      Parameters:
      expressionSpec - Target nested expression.
      Returns:
      a ProtoNestableTOExpr expression instance to select a specific column.
    • currentTimestamp

      public static CurrentTimestampSpec currentTimestamp()