DBTYPE
- The type of the data element, as represented in the database.CLASSTYPE
- The type of the data element, as represented in the Java class ENTITY
.ENTITY
- The type of the entity.BUILDER
- The class that is used to build new entity instances.public class ColumnImpl<DBTYPE,CLASSTYPE,ENTITY,BUILDER> extends Object implements Column<DBTYPE,CLASSTYPE,ENTITY,BUILDER>
Column
interface for data elements.
Most users of hrorm will have no need to directly use this.
Constructor and Description |
---|
ColumnImpl(GenericColumn<DBTYPE> genericColumn,
String prefix,
String name,
Function<ENTITY,CLASSTYPE> getter,
BiConsumer<BUILDER,CLASSTYPE> setter,
String sqlTypeName,
boolean nullable,
Converter<CLASSTYPE,DBTYPE> converter) |
Modifier and Type | Method and Description |
---|---|
GenericColumn<DBTYPE> |
asGenericColumn()
Returns a generic column instance that supports the underlying
DBTYPE |
static <T,E,B> Column<T,T,E,B> |
directColumn(GenericColumn<T> genericColumn,
String prefix,
String name,
Function<E,T> getter,
BiConsumer<B,T> setter,
String sqlTypeName,
boolean nullable) |
String |
getName()
The name of the database column this instance represents.
|
String |
getPrefix()
The prefix that should be used for this column when generating
SQL.
|
boolean |
isNullable()
Indicator of whether or not this column is nullable or not.
|
void |
notNull()
Calling this method will enforce a not-null constraint on this column.
|
PopulateResult |
populate(BUILDER builder,
ResultSet resultSet)
Populates the passed builder object with the data read from the database.
|
void |
setSqlTypeName(String sqlTypeName)
Set the name of the type of this column as it would be in the SQL schema.
|
void |
setValue(ENTITY item,
int index,
PreparedStatement preparedStatement)
Sets a value onto the prepared statement based on the state of the object passed.
|
CLASSTYPE |
toClassType(DBTYPE dbType)
Applies any
Converter associated with this column to
a raw database type. |
Column<DBTYPE,CLASSTYPE,ENTITY,BUILDER> |
withPrefix(String newPrefix,
Prefixer prefixer)
Make a new instance of the column, identical to this instance, except with a
new prefix.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fromResultSet, getSqlTypeName, isParentColumn, isPrimaryKey, supportedTypes
public static <T,E,B> Column<T,T,E,B> directColumn(GenericColumn<T> genericColumn, String prefix, String name, Function<E,T> getter, BiConsumer<B,T> setter, String sqlTypeName, boolean nullable)
public void setValue(ENTITY item, int index, PreparedStatement preparedStatement) throws SQLException
Column
setValue
in interface Column<DBTYPE,CLASSTYPE,ENTITY,BUILDER>
item
- The object to read the data from.index
- Where in the prepared statement to set the read valuepreparedStatement
- The statement being populatedSQLException
- allowed for PreparedStatement
operationspublic PopulateResult populate(BUILDER builder, ResultSet resultSet) throws SQLException
Column
populate
in interface Column<DBTYPE,CLASSTYPE,ENTITY,BUILDER>
builder
- The object being populatedresultSet
- The result said being readSQLException
- allowed for ResultSet
operationspublic String getName()
Column
public String getPrefix()
Column
public void notNull()
Column
public boolean isNullable()
Column
public void setSqlTypeName(String sqlTypeName)
Column
public Column<DBTYPE,CLASSTYPE,ENTITY,BUILDER> withPrefix(String newPrefix, Prefixer prefixer)
Column
public CLASSTYPE toClassType(DBTYPE dbType)
Column
Converter
associated with this column to
a raw database type.public GenericColumn<DBTYPE> asGenericColumn()
Column
DBTYPE
Copyright © 2019. All rights reserved.