- java.lang.Object
-
- org.mybatis.dynamic.sql.SqlColumn<T>
-
- All Implemented Interfaces:
BasicColumn,BindableColumn<T>,SortSpecification
public class SqlColumn<T> extends Object implements BindableColumn<T>, SortSpecification
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSqlColumn.Builder<T>
-
Field Summary
Fields Modifier and Type Field Description protected Stringaliasprotected booleanisDescendingprotected Class<T>javaTypeprotected JDBCTypejdbcTypeprotected Stringnameprotected ParameterTypeConverter<T,?>parameterTypeConverterprotected RenderingStrategyrenderingStrategyprotected SqlTabletableprotected BiFunction<TableAliasCalculator,SqlTable,Optional<String>>tableQualifierFunctionprotected StringtypeHandler
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<String>alias()Returns the columns alias if one has been specified.SqlColumn<T>as(String alias)Override the base method definition to make it more specific to this interface.SqlColumn<T>asCamelCase()Set an alias with a camel cased string based on the column name.ObjectconvertParameterType(T value)SortSpecificationdescending()Returns a new instance of the SortSpecification that should render as descending in an ORDER BY clause.booleanisDescending()Return true if the sort order is descending.Optional<Class<T>>javaType()Optional<JDBCType>jdbcType()Stringname()static <T> SqlColumn<T>of(String name, SqlTable table)static <T> SqlColumn<T>of(String name, SqlTable table, JDBCType jdbcType)StringorderByName()Return the phrase that should be written into a rendered order by clause.SqlColumn<T>qualifiedWith(String tableQualifier)Override the calculated table qualifier if there is one.Optional<RenderingStrategy>renderingStrategy()StringrenderWithTableAlias(TableAliasCalculator tableAliasCalculator)Returns the name of the item aliased with a table name if appropriate.SqlTabletable()Optional<String>typeHandler()<S> SqlColumn<S>withJavaType(Class<S> javaType)<S> SqlColumn<S>withParameterTypeConverter(ParameterTypeConverter<S,?> parameterTypeConverter)<S> SqlColumn<S>withRenderingStrategy(RenderingStrategy renderingStrategy)<S> SqlColumn<S>withTypeHandler(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 final String name
-
table
protected final SqlTable table
-
jdbcType
protected final JDBCType jdbcType
-
isDescending
protected final boolean isDescending
-
alias
protected final String alias
-
typeHandler
protected final String typeHandler
-
renderingStrategy
protected final RenderingStrategy renderingStrategy
-
parameterTypeConverter
protected final ParameterTypeConverter<T,?> parameterTypeConverter
-
tableQualifierFunction
protected final BiFunction<TableAliasCalculator,SqlTable,Optional<String>> tableQualifierFunction
-
-
Method Detail
-
name
public String name()
-
table
public SqlTable table()
-
jdbcType
public Optional<JDBCType> jdbcType()
- Specified by:
jdbcTypein interfaceBindableColumn<T>
-
alias
public Optional<String> alias()
Description copied from interface:BasicColumnReturns the columns alias if one has been specified.- Specified by:
aliasin interfaceBasicColumn- Returns:
- the column alias
-
typeHandler
public Optional<String> typeHandler()
- Specified by:
typeHandlerin interfaceBindableColumn<T>
-
convertParameterType
public Object convertParameterType(T value)
- Specified by:
convertParameterTypein interfaceBindableColumn<T>
-
descending
public SortSpecification descending()
Description copied from interface:SortSpecificationReturns a new instance of the SortSpecification that should render as descending in an ORDER BY clause.- Specified by:
descendingin interfaceSortSpecification- Returns:
- new instance of SortSpecification
-
as
public SqlColumn<T> as(String alias)
Description copied from interface:BindableColumnOverride the base method definition to make it more specific to this interface.- Specified by:
asin interfaceBasicColumn- Specified by:
asin interfaceBindableColumn<T>- Parameters:
alias- the column alias to set- Returns:
- new instance with alias set
-
qualifiedWith
public SqlColumn<T> qualifiedWith(String tableQualifier)
Override the calculated table qualifier if there is one. This is useful for sub-queries where the calculated table qualifier may not be correct in all cases.- Parameters:
tableQualifier- the table qualifier to apply to the rendered column name- Returns:
- a new column that will be rendered with the specified table qualifier
-
asCamelCase
public SqlColumn<T> asCamelCase()
Set an alias with a camel cased string based on the column name. The can be useful for queries using theCommonSelectMapperwhere the columns are placed into a map based on the column name returned from the database.A camel case string is mixed case, and most databases do not support unquoted mixed case strings as identifiers. Therefore the generated alias will be surrounded by double quotes thereby making it a quoted identifier. Most databases will respect quoted mixed case identifiers.
- Returns:
- a new column aliased with a camel case version of the column name
-
isDescending
public boolean isDescending()
Description copied from interface:SortSpecificationReturn true if the sort order is descending.- Specified by:
isDescendingin interfaceSortSpecification- Returns:
- true if the SortSpecification should render as descending
-
orderByName
public String orderByName()
Description copied from interface:SortSpecificationReturn the phrase that should be written into a rendered order by clause. This should NOT include the "DESC" word for descending sort specifications.- Specified by:
orderByNamein interfaceSortSpecification- Returns:
- the order by phrase
-
renderWithTableAlias
public String renderWithTableAlias(TableAliasCalculator tableAliasCalculator)
Description copied from interface:BasicColumnReturns 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:
renderWithTableAliasin interfaceBasicColumn- Parameters:
tableAliasCalculator- the table alias calculator for the current renderer- Returns:
- the item name with the table alias applied
-
renderingStrategy
public Optional<RenderingStrategy> renderingStrategy()
- Specified by:
renderingStrategyin interfaceBindableColumn<T>
-
withRenderingStrategy
@NotNull public <S> SqlColumn<S> withRenderingStrategy(RenderingStrategy renderingStrategy)
-
withParameterTypeConverter
@NotNull public <S> SqlColumn<S> withParameterTypeConverter(ParameterTypeConverter<S,?> parameterTypeConverter)
-
-