Package org.mybatis.dynamic.sql
Class SqlColumn<T>
- java.lang.Object
-
- org.mybatis.dynamic.sql.SqlColumn<T>
-
- All Implemented Interfaces:
BasicColumn
,BindableColumn<T>
,SortSpecification
public class SqlColumn<T> extends java.lang.Object implements BindableColumn<T>, SortSpecification
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SqlColumn.Builder
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
alias
protected boolean
isDescending
protected java.sql.JDBCType
jdbcType
protected java.lang.String
name
protected SqlTable
table
protected java.lang.String
typeHandler
-
Method Summary
Modifier and Type Method Description java.util.Optional<java.lang.String>
alias()
Returns the columns alias if one has been specified.java.lang.String
aliasOrName()
Return the column alias or column name.SqlColumn<T>
as(java.lang.String alias)
Override the base method definition to make it more specific to this interface.SortSpecification
descending()
Returns a new instance of the SortSpecification that should render as descending in an ORDER BY clause.boolean
isDescending()
Return true if the sort order is descending.java.util.Optional<java.sql.JDBCType>
jdbcType()
java.lang.String
name()
static <T> SqlColumn<T>
of(java.lang.String name, SqlTable table)
static <T> SqlColumn<T>
of(java.lang.String name, SqlTable table, java.sql.JDBCType jdbcType)
java.lang.String
renderWithTableAlias(TableAliasCalculator tableAliasCalculator)
Returns the name of the item aliased with a table name if appropriate.java.util.Optional<java.lang.String>
typeHandler()
static SqlColumn.Builder
withName(java.lang.String name)
SqlColumn<T>
withTypeHandler(java.lang.String typeHandler)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.mybatis.dynamic.sql.BasicColumn
renderWithTableAndColumnAlias
-
-
-
-
Field Detail
-
name
protected java.lang.String name
-
table
protected SqlTable table
-
jdbcType
protected java.sql.JDBCType jdbcType
-
isDescending
protected boolean isDescending
-
alias
protected java.lang.String alias
-
typeHandler
protected java.lang.String typeHandler
-
-
Constructor Detail
-
SqlColumn
protected SqlColumn(SqlColumn<?> sqlColumn)
-
-
Method Detail
-
name
public java.lang.String name()
-
jdbcType
public java.util.Optional<java.sql.JDBCType> jdbcType()
- Specified by:
jdbcType
in interfaceBindableColumn<T>
-
alias
public java.util.Optional<java.lang.String> alias()
Description copied from interface:BasicColumn
Returns the columns alias if one has been specified.- Specified by:
alias
in interfaceBasicColumn
- Returns:
- the column alias
-
typeHandler
public java.util.Optional<java.lang.String> typeHandler()
- Specified by:
typeHandler
in interfaceBindableColumn<T>
-
descending
public SortSpecification descending()
Description copied from interface:SortSpecification
Returns a new instance of the SortSpecification that should render as descending in an ORDER BY clause.- Specified by:
descending
in interfaceSortSpecification
- Returns:
- new instance of SortSpecification
-
as
public SqlColumn<T> as(java.lang.String alias)
Description copied from interface:BindableColumn
Override the base method definition to make it more specific to this interface.- Specified by:
as
in interfaceBasicColumn
- Specified by:
as
in interfaceBindableColumn<T>
- Parameters:
alias
- the column alias to set- Returns:
- new instance with alias set
-
isDescending
public boolean isDescending()
Description copied from interface:SortSpecification
Return true if the sort order is descending.- Specified by:
isDescending
in interfaceSortSpecification
- Returns:
- true if the SortSpcification should render as descending
-
aliasOrName
public java.lang.String aliasOrName()
Description copied from interface:SortSpecification
Return the column alias or column name.- Specified by:
aliasOrName
in interfaceSortSpecification
- Returns:
- the column alias if one has been specified by the user, or else the column name
-
renderWithTableAlias
public java.lang.String renderWithTableAlias(TableAliasCalculator tableAliasCalculator)
Description copied from interface:BasicColumn
Returns the name of the item aliased with a table name if appropriate. For example, "a.foo". This is appropriate for where clauses and order by clauses.- Specified by:
renderWithTableAlias
in interfaceBasicColumn
- Parameters:
tableAliasCalculator
- the table alias calculator for the current renderer- Returns:
- the item name with the table alias applied
-
of
public static <T> SqlColumn<T> of(java.lang.String name, SqlTable table, java.sql.JDBCType jdbcType)
-
withName
public static SqlColumn.Builder withName(java.lang.String name)
-
-