Class Field<T>

java.lang.Object
org.tentackle.dbms.dsl.Field<T>
Type Parameters:
T - the java type of the column
All Implemented Interfaces:
Expression<T>, SqlElement

public class Field<T> extends Object implements Expression<T>
A column of a table.

The name of a field is the column name as defined in the model, i.e. without the suffix of the second and following columns of a multi-column datatype (see DataType.getColumnSuffix(Backend, int)). The suffixes are added while rendering.

Author:
harald
  • Constructor Details

    • Field

      public Field(Table table, String name, DataType<T> dataType)
      Creates a field.
      Parameters:
      table - the table, null if unqualified
      name - the column name
      dataType - the datatype, null if untyped
  • Method Details

    • getTable

      public Table getTable()
      Gets the table this field belongs to.
      Returns:
      the table, null if unqualified
    • getName

      public String getName()
      Gets the column name.
      Returns:
      the name, without the suffix of multi-column datatypes
    • getColumnName

      public String getColumnName(Backend backend, int columnIndex)
      Gets the name of one of the columns of this field.
      Parameters:
      backend - the backend
      columnIndex - the column index, 0 for the first column
      Returns:
      the column name, suffixed for the second and following columns
    • getDataType

      public DataType<T> getDataType()
      Description copied from interface: Expression
      Gets the datatype of this expression.
      Specified by:
      getDataType in interface Expression<T>
      Returns:
      the datatype, null if untyped
    • render

      public void render(RenderContext context, int columnIndex)
      Description copied from interface: Expression
      Renders a single column of this expression.
      Specified by:
      render in interface Expression<T>
      Parameters:
      context - the render context
      columnIndex - the column index, 0 for the first column